Thread Rating:
  • 2 Vote(s) - 4.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tutorial Adding Localized Strings!
#1
Rainbow 
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:
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!

.rar   LocalizedStrings-Tutorial.rar (Size: 2.46 KB / Downloads: 186)

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
Obviously change CUSTOM_STRING_NAME to whatever your .str files are called

To use them with scripts, first precache them on init()
Code:
init()
{
    precacheString( &"MOD_SAY_HI" );
    precacheString( &"MOD_STUFF" );
}
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:
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!
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 Big Grin

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

Reply

#2
Very Helpfull man , this is really good Wink
Reply

#3
File approved.
Reply

#4
Great tutorial
[Image: lQDUjba.jpg]
Reply

#5
Can someone explain what a localized string is, or a string in general(mod newbie)
Reply

#6
Very well written tutorial, especially for a Fries <3
[Image: MaEIQ.png]
Reply

#7
Nice

btw: u like the word "orly" eh?
Reply

#8
4rly!

+rep good written, helpful
Reply

#9
(06-26-2011, 10:15)clxyeah Wrote: Can someone explain what a localized string is, or a string in general(mod newbie)

A string is the computerterm for a sequence of readable characters = text/sentence.

Localized means that it's translated (preferably in every possible language).

So a localized string means translated text -> the player will always read mod texts in his own language without forcing him to read English (which was pretty much default till now).
Reply

#10
I have error: ERROR! U(E)nable to load localizedstrings\modlang.str!
C++/Obj-Cdeveloper. Neko engine wip
Steam: Click
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
Information [Tutorial] Adding DLC Maps as Custom Maps. Nekochan 151 139,781 05-25-2013, 01:05
Last Post: Nero Z zero
  [HELP]Adding Spaces in a String dhanin 1 1,794 03-30-2013, 16:09
Last Post: Nukem
  Adding weapons in SP levels shafiq0895 2 3,151 12-13-2012, 16:13
Last Post: shafiq0895
  [Tutorial] Adding sounds to SP weapons (in multiplayer) Nukem 54 33,528 11-09-2012, 18:59
Last Post: The Tronuo
  Bo adding sounds need help! Will thank SamuelGrund 0 2,327 08-30-2012, 14:54
Last Post: SamuelGrund
  custom weapon intervention and adding 2+ custom weapons Gamemaster20 9 4,826 07-03-2012, 12:13
Last Post: zxz0O0
  Adding multiple attachments to guns. frozenliquid 2 2,597 01-05-2012, 17:00
Last Post: zabidenu
  Help Adding a new game mode! thethiny 6 2,936 10-17-2011, 17:41
Last Post: crAyon
  Adding music to mod? cervantes 7 3,472 09-21-2011, 11:34
Last Post: prisma
  adding cars ingame? unknown007 4 2,986 08-12-2011, 16:41
Last Post: unknown007

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2024 Melroy van den Berg.