-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
feat: 🧪 Support folder namespaces for intl #389
feat: 🧪 Support folder namespaces for intl #389
Conversation
Codecov Report
@@ Coverage Diff @@
## component-context-info-origin #389 +/- ##
=================================================================
+ Coverage 72.63% 72.72% +0.09%
=================================================================
Files 57 57
Lines 4915 4935 +20
Branches 959 966 +7
=================================================================
+ Hits 3570 3589 +19
- Misses 1345 1346 +1
Continue to review full report at Codecov.
|
Hi @achambers! Do you need any help with PR? |
@lifeart 👋 I'm taking over this PR from @achambers as he is on vacation atm and we're both on the same team 😃 I've just pushed an update there which tries to follow some of your advice from #344 (comment). Could you have a look and see if I'm on the right track? With regards testing this out I'm having a bit of difficulty. I'm struggling to manually verify my changes are working because I can't seem to make my VSCode see my local version of ELS rather than my installed one? Also with regards actual tests writing unit tests might be tricky due to the reliance on needing the ember-intl.js config file. I added some fixtures which may be a better way to verify this change but I've yet to write a test yet. thoughts? |
Hey @patocallaghan! Direction is good! According to tests, I think having few related unit tests should be fine:
here you could specify project file structure as 3rd argument (including intl config) - https://github.com/lifeart/ember-language-server/blob/component-context-info-origin/test/bultin-addons/core/intl-providers-test.ts#L73 to verify results it's key-value structure where key is a path to file, and value is file content: await getResult(
CompletionRequest.method,
connection,
{
'app/components/test.hbs': '',
'config/ember-intl.js': `module.exports = () => { ... }`
},
'app/components/test.hbs',
{ line: 0, character: 0 }
)
).response |
Thanks @lifeart, appreciate the advice. All makes sense. I'll be picking this up again on Monday 🙇♂️ |
return null; | ||
} | ||
|
||
return typeof intlConfig === 'function' ? intlConfig() : intlConfig; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lifeart This is perplexing me a bit as to how I should treat this intlConfig
. Essentially I want to return the IntlConfig
back as an object here. Debugging jest
is causing me a bit of pain to figure it out 😅
My debugger is telling me this is returned as function but even when I add intlConfig()
it's still returned as a function 😬 Is there something obvious I'm missing here?
config: {
'ember-intl.js': `module.exports = function() { return { wrapTranslationsWithNamespace: true } }`,
},
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, it may be jest problem, if it's acting as a function, try to toString()
it to figure out what is it.
In general, if tests is passing, it should work fine.
Provided config is correct.
@lifeart I think we're good to go now. It turned out to be some transient issue with my development environment 🤷♂️ Restarting VSCode (to finish an update) and clearing the Jest cache meant my debugging and testing started working as expected 🤦♂️ So I've noticed even though I can commit to Aaron's branch I don't have permissions to move this PR out of "Draft" and also to update the PR description. Could you do that for me and also add the following as the PR description please? Fixes #344 Ember Intl exposes a configuration file which allows you to configure the localization setup. One such setting is
|
# [2.26.0](v2.25.0...v2.26.0) (2022-07-22) ### Features * 🧪 Support folder namespaces for intl ([#389](#389)) ([9099c60](9099c60))
Just tested in our app and this works now! Thanks for the help @lifeart 👏 |
@patocallaghan @achambers Thank you for your work and contribution! |
@patocallaghan could you check this behaviour on your project? lifeart/els-intl-addon#6 (comment) |
@lifeart looking 👀 |
Yep I've noticed that intellisense doesn't work in all cases. Looking into it now. @toovy you mention the absolute path is off for your examples. How do you see the path? Also any chance you could pull together a test case using the test syntax similar to https://github.com/lifeart/ember-language-server/pull/389/files#diff-65bd0ca4089daf08ddfa3876799a64c1dc87e2629dfae17a16030a0c0b5aa8caR14 just so I can replicate what you are seeing? |
@patocallaghan I try to be as helpful as I can, still, I'm pretty busy at the moment.
This is what it looks like when I use the intellisense when the string is still empty: This is the result when e.g. choosing "Countries" (basically the complete path on my volume; correct would be This is how our translations folder looks like: No translation/no path outside the main YAML is taken into consideration for the intellisense at the moment. BR Tobi |
Thanks @toovy 🙇♂️ |
@toovy just curious but what editor are you using? I don't get any intellisense when it's I might create a test app to verify because at the minute all the unit tests I write in this repo to find the bug pass 🤔 Edit: I'm assuming it's VS Code but thought I'd ask anyway as I get a different experience than you. Edit: nvm found the bug 👍 |
Follow up to the bug found in #389 (comment) Make sure to generate the correct key name when the translation file as at the root translations directory, e.g. `translations/en-us.yml`. ### Before `.var.folders.mk.5t937px5627_y_j551f8gbkm0000gn.T.tmp-84101gxBh16jwQL7q.translations.admin.countries` ### After `admin.countries`
## [2.26.1](v2.26.0...v2.26.1) (2022-07-22) ### Bug Fixes * key name when translation file is at the root ([#392](#392)) ([4294adb](4294adb)), closes [/github.com//pull/389#issuecomment-1192553091](https://github.com//github.com/lifeart/ember-language-server/pull/389/issues/issuecomment-1192553091)
return null; | ||
} | ||
|
||
return typeof intlConfig === 'function' ? intlConfig() : intlConfig; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@patocallaghan I've been throwing this around in my head for a while. The config function takes an ember-cli environment
argument. While we don't do this I wonder if there's a world where people set different config based on the environment. I wonder whether we should pass development
in to the function just to be sure. Seeing as this is for intellisense, I think it's pretty safe to assume the ember-cli environment will be development
at that point.
Thoughts?
(Did a code search and here's one such example. I know passing in development
wouldn't affect the outcome here but it's an example of how the argument could be used.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, I'm up with specifying env = 'development' to intl config function, it could hep us implement #335
Yes, VS Code, thanks for fixing this! What is the simplest way to try it out without waiting for the release? Edit: Are there people using different IDEs at all? ;) |
@patocallaghan fix worked, no weird paths any more :) still, no nested files are analysed on my VSCode |
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)wrapTranslationsWithNamespace: true
wrapTranslationsWithNamespace: true
is not currently supported by this extension. This PR adds the ability, whenwrapTranslationsWithNamespace: true
is set inapp/config/ember-intl.js
, to support keys which have folders in their key names.