-
-
Notifications
You must be signed in to change notification settings - Fork 197
Global Translations Types #1432
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
base: dev
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
I think it makes sense to commit the type file, so that the types can be imported elsewhere in the codebase. It may also be worth moving it to a |
extension?.type.name | ||
); | ||
|
||
const locale = data.locales ? data.locales[0].name : defaultLocale; |
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.
const locale = data.locales ? data.locales[0].name : defaultLocale; | |
const locale = data.locales ? data.locales[0].name : defaultLocale.name; |
Because the default locale is defined as:
export const defaultLocale = {
name: "en-GB",
};
conf = JSON.parse(conf); | ||
|
||
return conf; | ||
console.log(configStr); |
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.
console.log(configStr); |
const JSONtoTS = require("json-to-ts"); | ||
|
||
class UVTranslationTypePlugin { | ||
// Define `apply` as its prototype method which is supplied with compiler as its argument |
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.
This file seems to have tabs in it, instead of two-space indentation.
// Generate translation types | ||
|
||
const enJSONStr = fs.readFileSync("./src/locales/en-GB.json").toString(); | ||
const enJSON = JSON.parse(enJSONStr.replace(/"\$/g, '"')); |
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.
Why the global replacement of dollar signs? This seems to have potential for side effects. If we don't want the dollar signs, should we just remove them from the files in the first place?
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.
Just added a couple of minor comments. I'm not sure I fully understand the implications of everything going on here -- e.g. why only process the English translations? Or is this just the first step?
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.
I was looking at the localeLoaders
and noticed that "pl-PL" (Polski) and "sv-SE" (Svenska) aren’t listed. I hope you don’t mind me asking, are these not part of the global translation type?
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.
@LanieOkorodudu, where are they missing? I see them listed in lines 88-89 of this file. Is there somewhere else?
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.
Apologies, I just realized I may have overlooked part of the code by not expanding it fully.
Progress
TODO
To Discuss
$moreInformation
totitle
. Cons: makes adding new translations complex, duplicate translation strings, excessive types and subtypes.Resolves #1383.