-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CHECKOUT-1234: Expose translation object #103
Conversation
Nice refactor 👍 |
4f0a7b4
to
d8e62c1
Compare
During testing, I discover that we're not formatting strings according to their locale when we merge multiple language files. It is an existing issue affecting the master branch at the moment. Currently, language files get cascaded - region-specific, regular and fallback (English) language files get merged in that order. In order to format these merged translations correctly, we need to have a An example of this problem: en.json { "items": "{count, plural, one{1 Item} other{# Items}}" } zh.json { "days": "{count, plural, other{# 天}}" } So if your preferred language is {{lang 'days' count=1}} <!-- Prints "1 天" -->
{{lang 'items' count=1}} <!-- Prints "1 Items" --> This is because Paper is using Chinese MessageFormat instance to format the fallback string, and Chinese doesn't have plurals. It only supports "other" http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html Anyway, I've made a new commit addressing the issue above. @mcampa @lord2800 @icatalina @jordanwink201 @PascalZajac, can you please take a look again? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
const Filter = require('./filter'); | ||
const LocaleParser = require('./locale-parser'); | ||
const Logger = require('../logger'); | ||
const Transformer = require('./transformer'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be nice if these const
were 🔤
🍹
good stuff 👍 |
d8e62c1
to
7e1cc85
Compare
💚 |
4546807
to
68e92d8
Compare
What?
Localizer
asTranslator
because the module only translates strings. AFAIK,localizer
is an internal module so the change in interface should be ok.lib/localizer.js missing coverage on line(s): 21, 57, 120, 136
.translations
object as a parameter by reference and directly assign formatters to that object. Generally speaking, we shouldn't modify parameters that are passed in by reference.hoek
.Why?
gettext
. We want to change that so it uses Stencil translation system. In order to do that, we need to expose the translated strings as a JSON object. So that it can be used to configure UCO.Testing / Proof
@bigcommerce/checkout @mcampa @lord2800 @mjschock