question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

We should make i18n-node much stricter.

See original GitHub issue
  1. We can set custom objectNotation character, . by default. For example we can set : character, but this character sets default values.
  2. 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.
  3. With objectNotation __("Error: user not found.") parsed as “Error” key with default value " user not found." etc…

We have two ways:

  1. Forbid using of whitespace with objectNotation. If string contains whitespace - skip handling it as path.
  2. 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:closed
  • Created 7 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
oliversalzburgcommented, May 6, 2016

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.

0reactions
mashpiecommented, May 6, 2016

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 try Database Error as key.

    {
        "Validation.Error.Required": " %s is mandatory",
        "Database Error: user not found.": "Database Error: user not found."
    }

with json objects flattened internaly i18n would than also try a search for Validation.Error.Required: %s is mandatory and fail but next find Validation.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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found