Tree shakable dictionary for e-commerce JS apps
npm install @ecomplus/i18n  
:brazil: :us:
Tree shakable dictionary focused on eCommerce JS applications.
> i18n ~ i19 ~ Internationalization
``bash`
npm i --save @ecomplus/i18n
`js${i19hello.en_us} ${i19visitor.pt_br}
import { i19hello, i19visitor } from '@ecomplus/i18n'
console.log()${i19hello.pt_br} ${i19visitor.pt_br}
// Hello Visitor
console.log()`
// Olá Visitante
We recommend using it with ecomUtils.i18n:
`js${i18n(i19hello)} ${i18n(i19visitor)}
import { i18n } from '@ecomplus/utils'
import { i19hello, i19visitor } from '@ecomplus/i18n'
console.log()`
// Hello Visitor
Change current language with ecomUtils._config:
`js${i18n(i19hello)} ${i18n(i19visitor)}
import { _config, i18n } from '@ecomplus/utils'
import { i19hello, i19visitor } from '@ecomplus/i18n'
_config.set('lang', 'pt_br')
console.log()`
// Olá Visitante
#### Import entire dictionary object
It'll output large size bundle, _not good for frontend apps_.
`js${dictionary.i19hello.en_us} ${dictionary.i19visitor.en_us}
import dictionary from '@ecomplus/i18n'
console.log()`
// Hello Visitor
You can import only one language variation using Webpack resolve.alias as following:
`js@ecomplus/i18n/src/${lang}/
// webpack.config.js
module.exports = {
//...
resolve: {
alias: {
'@ecomplus/i18n$': `
}
}
}
By this way you'll import only strings instead of objects:
`js${i19hello} ${i19visitor}
import { i19hello, i19visitor } from '@ecomplus/i18n'
console.log()`
// Hello Visitor
You can still use ecomUtils.i18n the same way:
`js${i18n(i19hello)} ${i18n(i19visitor)}
import { i18n } from '@ecomplus/utils'
import { i19hello, i19visitor } from '@ecomplus/i18n'
console.log()`
// Hello Visitor
1. String values always with uppercased first letter (eg.: 'Hello');const
2. Variable () names always in English;i19
3. Prefix for all variable names;i19helloWorld
4. String variables must be _camelCased_ (eg.: );i19OrderStatus
5. Object (enums) variables must be _PascalCased_ (eg.: );Msg
6. All language options must have same variables;
7. For long messages: variable name should be suffixed with ;Qn`;
8. For questions: variable name should be suffixed with
9. Exported constants must be alphabetically ordered;
10. Additional line break before objects (not for strings);