-
Notifications
You must be signed in to change notification settings - Fork 52
How to translate using vscode
vscode is a modern, open-source and free texteditor with tons of extensions, I use these for my translation project:
- Code Spell Checker - helps with finding typos
- Code Spell Checker - additional dictionary (needs to be explicitly added after installation, just read the extensions readme)
- Gitlens - helpful while working with git
- Markdown All in One - helpful while working with md-files (like this article)
- Markdown Table - i use this to autoformat the tables in the lexicon (in this wiki)
- Source Engine Support - for colored code in vdf- and txt-files
- DeepL for Visual Studio Code - to work with the DeepL API inside vscode
Visual Studio Code has an native UI/UX for git, but you still need to install GIT to use it in conjunction with github.
You cannot (and shouldn't for easier readability and merging) commit to the main repo.
What you do is create a fork (your own copy) to which you will commit your changes to.
Your codebase can be ahead (you did something) or behind (they did something) the changes in the main repo.
If your fork is behind, fetch and merge ... or just let it be done automatically with this.
If your fork is behind and ahead at the same time, do the same, fetch and merge (and hope for no conflicts).
If your fork is ahead, you can ask at the main repo for integration.
You'll do that through a pull request (abbreviated 'PR') which will - if it's fine - be merged into the main repo by an admin.
As long as your PR isn't merged by an admin you can still make commits and they will be automatically included in your current open PR, which means you do not have to close a PR just because there is something missing.
CI are automatically executed checks on your freshly added stuff to ensure least mistakes possible.
Click on Details, if the script stopped somewhere between the NEW_ACHIEVEMENT_* keys, the achievement-entries are not in sync between 563560_loc_your_language.vdf and reactivedrop_your_language.txt files. Solution: open up the utils folder and execute the translation-sync-tool to sync between these 2 files. It's easy to spot any changes made by the tool if you have a clean working tree (no uncommited changes), if you don't have one, don't forget you can stash away stuff for now and get it back later.
I f***** up hard, my commits are wrong, how can I get back to where I was?
Take a deep breath, cool down, make some copies of your hard work on your harddisk and reset back to the latest point where the main repo is. How?
Enter these 5 commands into your vscode's console:
git remote add upstream https://github.com/ReactiveDrop/reactivedrop_translations
git fetch upstream
git checkout master
git reset --hard upstream/master
git push origin master --force
Source: https://stackoverflow.com/questions/9646167/clean-up-a-fork-and-restart-it-from-the-upstream
DeepL is a translation service which doesn't cost anything (as long as you aren't translating > 500.000 characters per month).
It translates into the following languages:
Bulgarian, Chinese, Czech, Danish, Dutch, English, Estonian, Finnish, French, German, Greek, Hungarian, Indonesian, Italian, Japanese, Latvian, Lithuanian, Polish, Portuguese, Romanian, Russian, Slovak, Slovenian, Spanish, Swedish, Turkish
You just need an account and an API-Key, you'll find one here after you created your account.
There are for sure other services like DeepL (eg. libretranslate) but I'll use this one as my example here.
The DeepL-extension has its own settings including Api-Key, formality of translation and some more.
Throw your Api Key in there, so DeepL knows it's your account which is asking for translation strings.
vscode includes native support for regular expressions, open the find-bar (ctrl+f) and hit the rightmost icon in the search-box.
Here's a cheat sheet if you want to understand the syntax or want to create your own regex strings.
- Find your strings using the search-function and an regular expression
- Press Ctrl+Shift+L to (multi)select the found string(s) in your editor
- Press F1 to open Command Palette, there, select 'DeepL: Translate' (select your preferred language once), press Enter and voilà, your selected text has been translated, ready for proofreading.
Press Ctrl+Shift+F to open the project-wide search and enable regex again
(probably filter on *.txt files to ignore vdf-files which do not follow the standard of intending new lines)
Use this ^\t\t
in the searchbox and something like this *german*
in the box 'files to include' to get all untranslated lines
-
(?<=german": ).*$
finds with lookbehindgerman":
, then any character.
in any repetition*
and then end of line$
-
(?<= )"(.*?)"(?=,)
match any string which is predecessed by a space,
ahead -
(?<=german": )(?<= )"(.*?)"(?=,)
same with german only in its key -
(?<=german": )(?<=\s)"(.*?)"(?=,)
\s
for any whitespace char -
(?<=german": ")(.*?)(?=",)
same selection but without quotation marks -
^"(?!\[english).*clip
search for the word 'clip' in all non-english strings
-
\s*(?="\[english)(.*?)\n\s*
replace with\n
(the \s* in the end removes all whitespace chars until hitting the next key)
-
// .*\n
replace with nothing
-
\n\n
replace with\n
^\s*"(.*?)"
\t([A-Za-z0-9-]+)
^\s(?!\/\/)(?!GAME).*(?<!(\{|\}))(?<!")$
Want to find out how much there is to translate?
Search the whole project for files including *english*
and excluding *_loc_*
.
At the time of writing the result were 13.485 lines :)
(?!\s*($|//|\{|\}))(^((?!(<?xml|(.|..)list\]|"lang"|"Language"|"Tokens"|"appid"|"itemid"|english)).)*$)