Skip to content
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

Allow language files to be written as nested js objects instead of a single level #8444

Closed
julianlam opened this issue Jun 29, 2020 · 1 comment · Fixed by #8793
Closed
Milestone

Comments

@julianlam
Copy link
Member

A developer stumbling block relates to i18n and l8n, in that there is an expectation that:

  • for a language key such as [[my-file:category.key]]
  • the language file source would be found in /en-GB/my-file.json
  • my-file.json would be defined thusly:
{
  "category": {
    "key": "localisation"
  }
}

Whereas in reality it is actually:

{
  "category.key": "localisation"
}

We ought to support both because the former is used by some other frameworks (laravel perhaps?)

To work with our existing system, it is likely the file itself would just be parsed and then flattened before being send to the translator (whereas right now I bet it's something even simpler, like require('that-json-file');

Maybe there's even a lodash method for this hah!

@julianlam
Copy link
Member Author

Keep in mind core translations cannot be written in this manner, as Transifex expects a straight key value JSON file.

oplik0 added a commit to oplik0/NodeBB that referenced this issue Oct 24, 2020
oplik0 added a commit to oplik0/NodeBB that referenced this issue Nov 2, 2020
oplik0 added a commit to oplik0/NodeBB that referenced this issue Nov 15, 2020
oplik0 added a commit to oplik0/NodeBB that referenced this issue Nov 15, 2020
oplik0 added a commit to oplik0/NodeBB that referenced this issue Nov 17, 2020
oplik0 added a commit to oplik0/NodeBB that referenced this issue Nov 17, 2020
barisusakli pushed a commit that referenced this issue Nov 17, 2020
* feat: #8444 Allow nested objects in translations

* feat: #8444 Allow nested objects in translations

* style: don't change formatting

* fix: don't use the first string match if key isn't finished

* feat: #8444 Allow nested objects in translations

* feat: #8444 Allow nested objects in translations

* style: don't change formatting

* fix: don't use the first string match if key isn't finished

* feat: add nested translations test
@barisusakli barisusakli added this to the 1.15.2 milestone Nov 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants