Replies: 1 comment
-
Great article! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
What does i18n mean?
Style Guide
<page>.[section].<component>.[attribute]
camelCase
for multiple wordsBackground
Translation file (
en.yml
) is in YML format, but it's just replacement for JSON.What are possible ways to map strings in JSON?
You would probably start with plain object:
And you will create same file for each language, just changing values with translations.
But what if you decide later to change
New post
toAdd post
? You will need to change the key in all language files and in all source code files.Alternative way is to use more abstract keys, that gives you more flexibility. For example:
And what if you now have another feature:
Add event
? You alternatives are:Complex-word keys would be:
And what if now you have a login screen, which has a title, subtitle, 2 fields and submit button?
You might do this:
And what if you have a registration screen which have similar elements?
As you see translation file grows exponentially. You can make life easier for developers and translators by grouping keys:
When grouping elements look for similarities, what those elements have in common and how it would scale.
Input element can have label, placeholder, error. Those are attributes of that element, so it make sense to group values by element name, i.e. in our login screen:
But what if there are more error messages later? If we need to add error message for complexity validation (i.e. "Please use numbers, letters, special symbols"). Both are errors, so we would group them under errors.
How does this look in YML?
There multiple ways to describe objects in YML, the one that looks similar to JSON:
More on this topic:
Beta Was this translation helpful? Give feedback.
All reactions