We should make i18n-node much stricter.
See original GitHub issue- We can set custom objectNotation character,
.
by default. For example we can set:
character, but this character sets default values. - With objectNotation we still can use
__("Simple sentence with dot.")
(https://github.com/mashpie/i18n-node/pull/210, https://github.com/mashpie/i18n-node/pull/235), but__("Simple sentence with dot. Try it") + ":"
parsed as path. - With objectNotation
__("Error: user not found.")
parsed as “Error” key with default value " user not found." etc…
We have two ways:
- Forbid using of whitespace with objectNotation. If string contains whitespace - skip handling it as path.
- Leave all as is, but add
mixedMode
option to enable all from first point.
We should talk about it and decide which way we should choose. And i can help with implementation.
Issue Analytics
- State:
- Created 7 years ago
- Comments:11 (11 by maintainers)
Top Results From Across the Web
The Ultimate Guide to Node.js Internationalization (I18n)
This tutorial will try to fill that gap by showing ways of integrating i18n and adapting to different cultural rules and habits in...
Read more >node.js i18n: Use __ or import? - Stack Overflow
I am new to i18n and have an existing repository that uses it. I noticed different syntax for using i18n throughout the repository...
Read more >ivanhofer/typesafe-i18n: A fully type-safe and ... - GitHub
The generated types are really strict. It helps you from making unintentional mistakes. If you want to opt-out for certain translations, you can...
Read more >Why i18n is so hard - Drupal Groups
Basically. Because with more complex node types, some things are shared. Dates of events for example are the same with a different formatting....
Read more >Building a super small and simple i18n script in JavaScript
One of the trickier things is to determine which language the user wants in the first place. If this was the server-side (e.g....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Then I don’t understand why this ticket calls for making i18n more strict. It is very strict in that it supports either format. Mixing formats would mean making it less strict.
It might help to try multiple possible keys for finding. Example
__('Database Error: user not found.')
should 1st try to find the whole string
Database Error: user not found.
as key and stop or if none found also tryDatabase Error
as key.with json objects flattened internaly i18n would than also try a search for
Validation.Error.Required: %s is mandatory
and fail but next findValidation.Error.Required
This has to be tested carefully against all known use cases, though. And I still need a reasonable default for writing with
updateFiles: true
…