[Framework Request] Support a Mozilla webextension format
See original GitHub issueWhat framework do you want to have? Please provide links of its i18n solution/package. I’m using react-intl but with as custom converter method to support mozilla webextension format instead of plain json.
This has the advantage to add “descriptions” for every translation used by weblate translators. I added a custom framework definition which seems to work because the keys on my code are properly detected:
But ally seems not to be able to match the detected key to the localization files (I guess because of the sub-structure):
So my localization works like uses i18n with the exception that I don’t have simple key-value pairs in my json file. I’m using the WebExtension format:
"carport_mainComplaint": {
"message": "Main Complaint"
},
the before setting i18n to use the json files I conveert those object to the usual format:
type ObjStringProps = { [key: string]: string };
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function convertWebExtensionFormatToI18n(jsonObj: any): ObjStringProps {
const result = { default: '' } as ObjStringProps; //default is always part of an object, so create it here explicitly to be TSC compatible
for (const prop in jsonObj) {
result[prop] = jsonObj[prop].message as string;
}
delete result.default;
return result;
}
How do I need to define an ally custom framework to support this mapping?
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (1 by maintainers)
Top GitHub Comments
Hi, thanks to @antfu I got it to work meanwhile. Defining
refactorTemplates
with the used method and turning offmonopoly
works:This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.