VS Code extension for easily translating localization files using Chat GPT.
Setting OpenAI API key
If you don't have an OpenAI API key, check the section below to see how to create one.
Once when the extension is installed, open settings from the main menu: File -> Preferences -> Settings.
Switch to the Workspace tab and type 'ai-localization' in the search bar. Paste your OpenAI API key in the field 'Ai-localization: Chat GPTApi Key'.
Now the extension is ready.
NOTE: Your balance must be higher than zero in order to use the OpenAI API.
File structure requirements
In order for the extension to function properly, all localization files must fulfill the following requirements:
- All localization files must reside inside one directory.
- Localization files must be in JSON format.
- File names must represent localization codes. For example, all following file names are valid representations of a localization code:
en_us.json
,enUs.json
,en-us.json
,En US.json
, etc.
Open a localization file that will be used as a source for translation. If the file has a .json
extension two additional options will be available in the right-click menu inside the editor: Translate All
and Translate Missing
.
The Translate All
option will overwrite all existing entries in other localization files with new translations. This option can take some time depending on the number of entries and languages.
The Translate Missing
option will translate only entries that are not present in other localization files, that way invoking less number of requests.
When translation is invoked, entries are split into separate requests for performance and limitation of maximal character number. This option controls how many translated phrases will be retrieved by one request. This option is correlated with the length of text that is being translated. If text entries are too long then this parameter should be a smaller number so responses could be generated properly.
NOTE: If you notice that some entries can't be translated, try setting a smaller value for this parameter and try again.
Which Chat GPT model the extension will use for translation.
NOTE: For more information about available models check this page.
NOTE: By default the gpt-3.5-turbo model is used. Other models are more expensive but have better performance.
All double quotes are replaced with single quotes because they can cause JSON response to be invalid.
If translated text is too long it might not be possible to be translated. In that situation the Max Translations Per Response
option can be reduced or another model can be selected with a higher number of output tokens.
It is possible that Chat GPT API returns invalid JSON. Or a valid JSON that doesn't contain all translations, so in that case it's not reliable to apply translations.
Go to https://platform.openai.com/ page and create an account. Once when you are logged in, select the API keys
from the left menu, or open this page directly.
Click the Create new secret key
button, name the key and click Create secret key
.
Copy and save the key that appears on the screen, because you won't be able to access it later anymore.
This extension uses content generated by third-party artificial intelligence (AI) services. The author of this extension is not responsible for any content generated by the AI nor any damage or losses caused by usage of this extension.