-
Notifications
You must be signed in to change notification settings - Fork 2
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
add ts support for i18n strings #217
Conversation
Resolves: #94
6830c9d
to
fd72335
Compare
TODO: #216 (review)
|
…add-ts-support-for-i18n-strings
the word "language" had double usage; on the one hand for actual translations, on the other for a chosen language (like "en") this has been separated by this commit, actual translations are now referred to as "locales" this changes the PLUGIN API (BREAKING)
…add-ts-support-for-i18n-strings
The transferred TODOs have been adressed and this PR is ready for review. Since it introduces breaking changes, I advise to merge it before we do the breaking change regarding OL to have it released in the same cycle. |
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.
Personally, I'm not really a fan of loosing the history of a file but it seems negligible for the locales and probably more of a hazzle to preserve it so it seems the way to go.
The autocompletion works like a charm in most files but I don't seem to get it running in any .vue
-files. I also have errors constantly being displayed inline about a type mismatch (like before). Did you add any configurations to your IDE for it to work in .vue
-files?
I also think its a bit irritating that you (justly) removed all common
-namespace-prefixes but the autocompletion adds the namespace on autocompletion. Do you know if that can be configured or that is something we simply have to live with?
The removal of all tsconfig.json
-files seems to be of no problem, as far as I can tell. If I add a TS error, the respective command still informs me of said error.
apply suggestion "consistently rename lng" Co-authored-by: Pascal Röhling <73653210+dopenguin@users.noreply.github.com>
apply suggestion "shorten expression" Co-authored-by: Pascal Röhling <73653210+dopenguin@users.noreply.github.com>
Did we really lose it? In the commit, it looks like git realized the files were merely renamed: 57eabf3#diff-f5ec52c63439dddd1ea390e39d788dcef27be3a556007a80dc0d3b3328ab7b33
No, I didn't change anything. But all
My autocompletion doesn't do that. |
Yeah, you're right. GitHub just displays is like that in the UI. If I look at the files in my IDE, it is fine.
Hm, that is kind of sad, that only VSC has that support. But maybe that will change with Vue@3 for me as well.
Hm, weird. |
apply suggestion "unify import" Co-authored-by: Pascal Röhling <73653210+dopenguin@users.noreply.github.com>
🏓 @dopenguin ponging intensifies |
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.
Personally, I'm not really a fan of loosing the history of a file but it seems negligible for the locales and probably more of a hazzle to preserve it so it seems the way to go.
Did we really lose it? In the commit, it looks like git realized the files were merely renamed: 57eabf3#diff-f5ec52c63439dddd1ea390e39d788dcef27be3a556007a80dc0d3b3328ab7b33
Yeah, you're right. GitHub just displays is like that in the UI. If I look at the files in my IDE, it is fine.
The autocompletion works like a charm in most files but I don't seem to get it running in any
.vue
-files. I also have errors constantly being displayed inline about a type mismatch (like before). Did you add any configurations to your IDE for it to work in.vue
-files?No, I didn't change anything. But all
.vue
file support stops if I disable this vsc extension, so I guess that's somewhere under the hood there. The service reporting errors signs asts-plugin
.Hm, that is kind of sad, that only VSC has that support. But maybe that will change with Vue@3 for me as well.
I also think its a bit irritating that you (justly) removed all
common
-namespace-prefixes but the autocompletion adds the namespace on autocompletion. Do you know if that can be configured or that is something we simply have to live with?My autocompletion doesn't do that.
Hm, weird.
🏓 @dopenguin ponging intensifies
Summary
language.ts
locales
according to this example folder structure; maybe all files should be namedlocales.ts
instead? Asking for approval before changing, please block or confirm this effort.tsconfig.json
. This enabled$t('')
support in templates for me, so I assume something was wrong with them anyway and TS now falls back to the globaltsconfig.json
when doing anything.common:
prefix since we don't have multiple namespaces andcommon:
is the default namespace anyway, so even if we move ahead to add additional namespaces, there is no need to add the prefix.Instructions for local reproduction and review
$t('')
breaks in vue andi18n.$t('')
breaks outside of vue. Since''
is not a valid locale string, both should fail, id est throw some sort of error in your IDE (and, outside of.vue
files, in the type check). You should also get autocompletion when typing out a new$t
statement.tsconfig.json
files. Seems to just work to me.Caveats
.vue
files 100% and some edge cases in clients remain where a calculated locale keys (e.g.something.${string}
) do not match the pattern (type is a genericstring
), but work perfectly fine nonetheless. Since TS is not well-supported in Vue@2 anyway and lots of errors remain, I don't really think that detail's worth the effort.Relevant tickets, issues, et cetera
Resolves: #94