Localize rest of strings #221
Labels
feature-request
Request for new features or functionality
verification-needed
Verification of issue is requested
verified
Verification succeeded
Milestone
Now that #220 is in, localizing the rest of the strings should be straightforward.
Step 1:
localize
callsFor every file that contains a user facing string, you'll do the following:
localize()
. Here are some examples:Additional context around the localize call
Let's take this example:
The first parameter is either just a string which represents the
key
or an object that has akey
and acomment
property.The
key
isn't really important, it's just an identifier of the string. You can put whatever you want there, it just has to be unique to the TS file that contains the string. Yes, this means that you could reuse the same key across different TS files so if that makes sense for you, don't be afraid to do that.The
comment
section is a way to manipulate how the string is translated. You can either use the special{Locked=''}
syntax which is called "functional commenting" (docs on functional commenting), or you can use a normal comment which will be shown to the translator responsible for translating the string. Using both is ideal because the functional commenting also applies to the Pseudo Language generation which a human is not involved with and the normal comments help describe our code better.The next thing we have is the actual literal string that will be sent to translators. Let me be clear. The EXACT string that a translator will see is
translate me but do not translate me but also here is a parameter: {0}
(even with the{0}
part). This is because our strings are sent over at build time - not runtime. It's important that this parameter is completely static (no concatenation, no interpolation, nothing) because we scan the TS for the strings and do not run the code at all.The final parameter(s) of our call are the segments of the string that will be filled in at runtime. When VS Code runs, it will take the value of these parameters and replace the
{0} {1} {2}
etc syntax with the respective parameters passed in after the string to be translated.Step 2:
package.nls.json
The other strings that we need to translate are found in your
package.json
. You'll have plenty of strings in thecontributes
section. These strings can be moved over to apackage.nls.json
file and look like so:The keys of these strings are then referenced in the
package.json
with%
around them like so:The text was updated successfully, but these errors were encountered: