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

implement /config/intl.js execution to get intl configurations (translations location, nesting, default locations, etc) #344

Closed
Tracked by #342
lifeart opened this issue Dec 8, 2021 · 2 comments · Fixed by #389
Labels
enhancement New feature or request

Comments

@lifeart
Copy link
Owner

lifeart commented Dec 8, 2021

No description provided.

@achambers
Copy link

achambers commented Jun 10, 2022

Hi @lifeart. Have you had any thoughts about how this might be implemented. I'm currently exploring improving this project to support translation keys that use the folder structure to namespace keys, ie for translations/foo/bar/en.yml -> foo.bar.some.key instead of some.key which is what is supported currently.

In order to know whether we should be namespacing the keys we need to get access to the config/ember-intl.js file, in particular the wrapTranslationsWithNamespace property.

Wondering if you've put any thought in to how we might go about doing this?

(For reference, I've started knocking together a PR to explore what needs to be done to actually namespace the keys. It's a proof of concept more than anything as I've not written any language server code before. Just an FYI.

@lifeart
Copy link
Owner Author

lifeart commented Jun 10, 2022

Hi @achambers! Thank you for your initiative! I think it's really good!

Simplest way is to do dynamic "import" for this file, later, we could use worker_threads to isolate it.
Take a look on how we load environment.js right now: https://github.com/lifeart/ember-language-server/blob/component-context-info-origin/src/utils/layout-helpers.ts#L87

lifeart pushed a commit that referenced this issue Jul 22, 2022
Fixes #344

Ember Intl exposes a configuration file which allows you to configure the localization setup. One such setting is `wrapTranslationsWithNamespace` which determines whether translation keys should have the folder names within the key names.

#### `wrapTranslationsWithNamespace: false` (default)
```yml
# translations/sub-folder/en-us.yml
subFolder:
  foo: bar
```
```js
this.intl.t('subFolder.foo');
```

#### `wrapTranslationsWithNamespace: true`
```yml
# translations/sub-folder/en-us.yml
subFolder:
  foo: bar
```
```js
this.intl.t('sub-folder.subFolder.foo');
```
`wrapTranslationsWithNamespace: true` is not currently supported by this extension. This PR adds the ability, when `wrapTranslationsWithNamespace: true` is set in `app/config/ember-intl.js`, to support keys which have folders in their key names.

Co-authored-by: Pat O'Callaghan <pat@intercom.io>
@lifeart lifeart added the enhancement New feature or request label Jul 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants