INTRODUCTION
In this tutorial i will show how to put in localized strings for each langauge!
first off, you will need a mod (orly?).
make the following folders:
For this tutorial I've made a little example, download it! It makes this tutorial soo much easier. Unrar it in your mod folder and you should have every langauge folder in your MODROOT!
LocalizedStrings-Tutorial.rar (Size: 2.46 KB / Downloads: 193)
A STRING FILE
Now I will explain how the .str file is made and what it contains
For administration purpose we always start with the following 3 lines:
The VERSION line is very handy in case you update your strings alot, again its just for administration purpose. I never changed the CONFIG line, not sure if it really matters because obviously StringED.cfg doesn't exist... Anyway, just leave it there.
FILENOTES is just a little line that contains some optional notes about the current localized strings file.
After those 3 lines we start with the strings itsself. Here is an example of a localized string(they are included in the .rar you downloaded earlier)
As you see a "string" contains 2 lines, The first line is the REFERENCE which is the name you use in your scripts. LANG_[LANGAUGE] is the text it displays for the langauge you are making, in this case its English so we use LANG_ENGLISH. Now when I use "MOD_SAY_HI" in my mod it will actually display "Hi Everyone!" in green (because "^2" == green).
When we are done with our strings, we can end the file with the following line:
In the end your file should look like this:
MAKING IT MULTILANGUAGE
Localized strings are not just a good way of adding strings, they are also multi-langauge, which means people with a German game will see german text (if you set it right) and people with a Spanish game will see spanish text!
As you've seen in the .rar file you downloaded before there are 7 folders, and each folder contains a different language. Above we made an English file so that should be saved in mp_YOURMOD\english\localizedstrings\CUSTOM_STRING_NAME.str. Now we are going to add other languages to your mod.
Here is a list of LANG_[Language] things you have to use for each language
For each language you create a new .str file all WITH THE SAME NAME. In the example you downloaded you see I called them Mod.str, You have to put each language in the right language folder. So in the example I ended up with the following files:
USING AND COMPILING THEM
We have to put them into a FastFile otherwise they will not work! Because every .str file has the same name we only have to add one line to our zone source which is the following line:
Obviously change CUSTOM_STRING_NAME to whatever your .str files are called
To use them with scripts, first precache them on init()
Make sure to use the & symbol in front of it because the string is a Localized String!
Now you can use them in any text related function.. for example:
As you see in the sayAll() function I used a variable which is "self.name", You might have noticed that in the second string there is a strange symbol (&&1). This symbol is basicly an undefined word, it has to be defined by scripts. So in this case &&1 will be replaced by the player name which will then make the string:
If you want to add multiple "&&x" symbols to one string, make sure you use &&1 for the first word, &&2 for the second and so on.
Lets hope I didn't do anything wrong, otherwise everyone will screw up and spam this thread with problems
Questions? Ask them and if its something very confusing/much asked question I'll add it to the first post!
In this tutorial i will show how to put in localized strings for each langauge!
first off, you will need a mod (orly?).
make the following folders:
Code:
mp_YOURMOD\english\localizedstrings\
mp_YOURMOD\german\localizedstrings\
mp_YOURMOD\spanish\localizedstrings\
mp_YOURMOD\russian\localizedstrings\
mp_YOURMOD\french\localizedstrings\
mp_YOURMOD\italian\localizedstrings\
mp_YOURMOD\portuguese\localizedstrings\
For this tutorial I've made a little example, download it! It makes this tutorial soo much easier. Unrar it in your mod folder and you should have every langauge folder in your MODROOT!
LocalizedStrings-Tutorial.rar (Size: 2.46 KB / Downloads: 193)
A STRING FILE
Now I will explain how the .str file is made and what it contains
For administration purpose we always start with the following 3 lines:
Code:
VERSION "1"
CONFIG "C:\projects\cod\t5\bin\StringEd.cfg"
FILENOTES ""
The VERSION line is very handy in case you update your strings alot, again its just for administration purpose. I never changed the CONFIG line, not sure if it really matters because obviously StringED.cfg doesn't exist... Anyway, just leave it there.
FILENOTES is just a little line that contains some optional notes about the current localized strings file.
After those 3 lines we start with the strings itsself. Here is an example of a localized string(they are included in the .rar you downloaded earlier)
Code:
REFERENCE MOD_SAY_HI
LANG_ENGLISH "^2Hi Everyone!"
REFERENCE MOD_STUFF
LANG_ENGLISH "&&1 Says Hi!"
As you see a "string" contains 2 lines, The first line is the REFERENCE which is the name you use in your scripts. LANG_[LANGAUGE] is the text it displays for the langauge you are making, in this case its English so we use LANG_ENGLISH. Now when I use "MOD_SAY_HI" in my mod it will actually display "Hi Everyone!" in green (because "^2" == green).
When we are done with our strings, we can end the file with the following line:
Code:
ENDMARKER
In the end your file should look like this:
Code:
VERSION "1"
CONFIG "C:\projects\cod\t5\bin\StringEd.cfg"
FILENOTES ""
REFERENCE MOD_SAY_HI
LANG_ENGLISH "^2Hi Everyone!"
REFERENCE MOD_STUFF
LANG_ENGLISH "&&1 Says Hi!"
ENDMARKER
MAKING IT MULTILANGUAGE
Localized strings are not just a good way of adding strings, they are also multi-langauge, which means people with a German game will see german text (if you set it right) and people with a Spanish game will see spanish text!
As you've seen in the .rar file you downloaded before there are 7 folders, and each folder contains a different language. Above we made an English file so that should be saved in mp_YOURMOD\english\localizedstrings\CUSTOM_STRING_NAME.str. Now we are going to add other languages to your mod.
Here is a list of LANG_[Language] things you have to use for each language
Code:
LANG_ENGLISH - English
LANG_SPANISH - Spanish
LANG_PORTUGUESE - Portuguese
LANG_GERMAN - German
LANG_FRENCH - French
LANG_RUSSIAN - Russian
LANG_ITALIAN - Italian
For each language you create a new .str file all WITH THE SAME NAME. In the example you downloaded you see I called them Mod.str, You have to put each language in the right language folder. So in the example I ended up with the following files:
Code:
mp_YOURMOD\english\localizedstrings\mod.str
mp_YOURMOD\german\localizedstrings\mod.str
mp_YOURMOD\spanish\localizedstrings\mod.str
mp_YOURMOD\russian\localizedstrings\mod.str
mp_YOURMOD\french\localizedstrings\mod.str
mp_YOURMOD\italian\localizedstrings\mod.str
mp_YOURMOD\portuguese\localizedstrings\mod.str
USING AND COMPILING THEM
We have to put them into a FastFile otherwise they will not work! Because every .str file has the same name we only have to add one line to our zone source which is the following line:
Code:
localize,CUSTOM_STRING_NAME
To use them with scripts, first precache them on init()
Code:
init()
{
precacheString( &"MOD_SAY_HI" );
precacheString( &"MOD_STUFF" );
}
Now you can use them in any text related function.. for example:
Code:
onPlayerSpawned()
{
self endon( "disconnect" );
while( true )
{
self waittill( "spawned_player" );
self iPrintLnBold( &"MOD_SAY_HI" );
self sayAll( &"MOD_STUFF", self.name );
}
}
As you see in the sayAll() function I used a variable which is "self.name", You might have noticed that in the second string there is a strange symbol (&&1). This symbol is basicly an undefined word, it has to be defined by scripts. So in this case &&1 will be replaced by the player name which will then make the string:
Code:
iAegle Says Hi!
Lets hope I didn't do anything wrong, otherwise everyone will screw up and spam this thread with problems
Questions? Ask them and if its something very confusing/much asked question I'll add it to the first post!
(08-10-2011, 12:58)Pozzuh Wrote:Se7en Wrote:Stealed, from cod4 mod ...look who's talking
[Release] Old School Mod v2.2
[Release] Scroll menu