パッケージの詳細

@ecomplus/i18n

ecomplus861MIT1.32.2

Tree shakable dictionary for e-commerce JS apps

ecommerce, dictionary, translations, ecomplus

readme

i18n

Publish npm version License MIT

:brazil: :us:

Tree shakable dictionary focused on eCommerce JS applications.

i18n ~ i19 ~ Internationalization

Getting started

npm i --save @ecomplus/i18n

Usage

import { i19hello, i19visitor } from '@ecomplus/i18n'
console.log(`${i19hello.en_us} ${i19visitor.pt_br}`)
// Hello Visitor
console.log(`${i19hello.pt_br} ${i19visitor.pt_br}`)
// Olá Visitante

We recommend using it with ecomUtils.i18n:

import { i18n } from '@ecomplus/utils'
import { i19hello, i19visitor } from '@ecomplus/i18n'
console.log(`${i18n(i19hello)} ${i18n(i19visitor)}`)
// Hello Visitor

Change current language with ecomUtils._config:

import { _config, i18n } from '@ecomplus/utils'
import { i19hello, i19visitor } from '@ecomplus/i18n'
_config.set('lang', 'pt_br')
console.log(`${i18n(i19hello)} ${i18n(i19visitor)}`)
// Olá Visitante

Import entire dictionary object

It'll output large size bundle, not good for frontend apps.

import dictionary from '@ecomplus/i18n'
console.log(`${dictionary.i19hello.en_us} ${dictionary.i19visitor.en_us}`)
// Hello Visitor

Webpack alias

You can import only one language variation using Webpack resolve.alias as following:

// webpack.config.js
module.exports = {
  //...
  resolve: {
    alias: {
      '@ecomplus/i18n$': `@ecomplus/i18n/src/${lang}/`
    }
  }
}

By this way you'll import only strings instead of objects:

import { i19hello, i19visitor } from '@ecomplus/i18n'
console.log(`${i19hello} ${i19visitor}`)
// Hello Visitor

You can still use ecomUtils.i18n the same way:

import { i18n } from '@ecomplus/utils'
import { i19hello, i19visitor } from '@ecomplus/i18n'
console.log(`${i18n(i19hello)} ${i18n(i19visitor)}`)
// Hello Visitor

Conventions

  1. String values always with uppercased first letter (eg.: 'Hello');
  2. Variable (const) names always in English;
  3. Prefix i19 for all variable names;
  4. String variables must be camelCased (eg.: i19helloWorld);
  5. Object (enums) variables must be PascalCased (eg.: i19OrderStatus);
  6. All language options must have same variables;
  7. For long messages: variable name should be suffixed with Msg;
  8. For questions: variable name should be suffixed with Qn;

Code style

  1. Exported constants must be alphabetically ordered;
  2. Additional line break before objects (not for strings);

更新履歴

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

1.32.2 (2022-09-27)

1.32.1 (2022-09-27)

Bug Fixes

  • Add named export for each lang on package.json (656353f)

1.32.0 (2022-09-27)

Features

  • words: new i19myAccountAndOrders (0675fb8)

1.31.0 (2022-08-11)

Features

  • words: words for subscriptions admin (#179) (b826990)

1.30.0 (2022-08-05)

Features

1.29.0 (2022-03-25)

Features

1.28.0 (2022-03-18)

Features

1.27.0 (2022-02-05)

Features

1.26.0 (2022-01-10)

Features

  • words: add new i19sizeGuide (fae84f3)

1.25.0 (2022-01-03)

Features

1.24.0 (2021-10-23)

Features

1.23.0 (2021-08-04)

Features

Bug Fixes

  • pt-br: typo fix i19loyaltyPoints and i19loyaltyPointsName (#127) (9e39e65)

1.22.0 (2021-06-04)

Features

1.21.0 (2021-05-17)

Features

1.20.0 (2021-02-09)

Features

1.19.0 (2021-02-09)

Features

1.18.0 (2020-12-19)

Features

1.17.0 (2020-11-07)

Features

1.16.1 (2020-09-13)

Bug Fixes

  • object: fix i19InscriptionType enums (c1d4b74)

1.16.0 (2020-09-11)

Features

1.15.0 (2020-08-27)

Features

  • words: add 'savedWithSuccess' en_us (#76) (959f862)
  • words: add 'savedWithSuccess' pt_br (#75) (68f993a)
  • words: new words for product's list (#72) (3895621)
  • words: new words for product's list (en_us) (#73) (43c0307)
  • words: new words from #69 (46766de)

1.14.0 (2020-07-15)

Features

Bug Fixes

  • pt-br: fix i19fullName ptBr translation (#66) (0589124)

1.13.0 (2020-06-14)

Features

1.12.0 (2020-06-09)

Features

1.11.1 (2020-05-28)

Bug Fixes

  • pt-br: fix i19on ptBR translation (30aa8a7)

1.11.0 (2020-05-22)

Features

  • words: fix i19filterResults (pt), add i19editFilters (c1f7373)

1.10.1 (2020-05-16)

Bug Fixes

  • words: fix 'i19ofDiscount' and 'i19onFreight' ptBR (4368df5)

1.10.0 (2020-05-15)

Features

1.9.0 (2020-05-05)

Features

  • words: minor fixes and new words from #48 (04279b9)

1.8.0 (2020-04-23)

Features

  • words: add i19or, i19asOf, i19with (c940af6)

1.7.1 (2020-04-20)

Bug Fixes

  • pt-br: fix i19inStock to 'Em estoque' (a37fc27)
  • pt-br: fix i19only to 'Apenas' (45a194c)

1.7.0 (2020-03-26)

Features

1.6.0 (2020-03-23)

Features

  • words: adding new words and minor fixes #42 (4f81071)

1.5.0 (2020-03-18)

Features

Bug Fixes

  • js: syntax for for unscaped quote (d169d35)

1.4.1 (2020-02-28)

1.4.0 (2020-02-28)

Features

  • words: new words from storefront (#31) (8027a54)

1.3.2 (2020-02-11)

1.3.1 (2019-12-08)

Bug Fixes

  • words: fix 'recipient' pt_br translation (674a8de)
  • words: fix 'shippingAddress' pt_br translation (1f69795)

1.3.0 (2019-12-08)

Features

  • words: new words from market (#14) (b71ed17)
  • words: some more discount coupon related words/message (4aa0f15)

1.2.0 (2019-12-03)

Features

  • new words from order resources and admin marketplace (#13) (086ed15)

Bug Fixes

  • words: fix some words related to discount coupon (ac55719)

1.1.1 (2019-11-23)

1.1.0 (2019-11-17)

Features

1.0.0 (2019-11-12)

⚠ BREAKING CHANGES

  • const-names: all named exports changed

Features

  • const-names: add prefix 'i19' following new conventions (#6) (6a9aec3)

Bug Fixes

  • phone-type: fix convention, always capitalized (cb8224f)
  • fixing words updates (628ee1f)

0.1.2 (2019-11-07)

Features

0.1.1 (2019-11-07)

Bug Fixes

  • conventions: always capitalized (0d7cca2)

Features

  • exports: multiple exports options on default entry file (c0806e6)
  • exports: named exports of each word with multiple langs (58e2da9)
  • lot of new dictionary words (#3) (19ede04)
  • new words and alphabetical order (b043c49)
  • langs: separated files by lang (e35431a)
  • setup index with basic strings (d899c94)