-
Notifications
You must be signed in to change notification settings - Fork 119
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
[bug] Message IDs clashing with internal variables #1938
Comments
@LorisSigrist I think this relates to index functions for the languages. Nasty edge case. |
On it! |
This isn't an indonesia-specific edge case. This happens whenever there is a message that shares a name with a language tag. The import The same issue would happen if the ID "languageTag" were to be used. |
@LorisSigrist can you make a loom? The issue is a bit abstract to follow |
Alternatively, we could also keep the names of the internal and instead give the message functions random names, and then only export them at the very end. This would keep the interface a little prettier since we wouldn't need to rename Eg: import * as id from "./messages/id.js"
const id_2374865 = (params, options) => {
...
}
const other_message_30981 = (params, options) => {
...
}
export {
id_2374865 as id,
other_message_30981 as other_message
}; Once the random-id proposal hits this will be much less of an issue |
@LorisSigrist I don't understand why params and options need to be renamed. They are scoped variables. Generally, this seems like a non-issue. Don't name your messages like language tags and the problem is gone. #1892 will further strengthen this. The downsides of hashing stuff that come to mind:
@4kimov can you confirm that the bug was triggered because you named a message "id"? |
@samuelstroschein Yes, I saw the error when I created the file Edit: I'm assuming by "message" you mean the filename. Inside that JSON file, I also have the key by the name |
That is the root cause. Don't name your key like a language tag. The issue is so rare that we will likely not implement logic (which adds complexity) to solve this issue. Besides, we will introduce automatically generated names to avoid issues like these and increase the DX with #1892. |
Ah, I didn't know that. Ok thank you for the heads up! |
Problem
When using
"@inlang/paraglide-js": "1.0.0-prerelease.20"
and having translations for Bahasa Indonesia, whose language id is "id", the following bug appears:Uncaught (in promise) SyntaxError: Identifier 'id' has already been declared
On this line (from what I understand is an internally generated function):
export const id = (params = {}, options = {}) => {
Expected behavior
The error should not happen.
Reproduction
Create a
messages/id.json
file.Other information
No response
The text was updated successfully, but these errors were encountered: