DGS Multilingual: Difference between revisions
Jump to navigation
Jump to search
m (Thisdp moved page DGS Multilingul to DGS Multilingual) |
No edit summary |
||
Line 6: | Line 6: | ||
==<span style="color:#000000;text-shadow:0.05em 0.05em 0.2em #00000099;">Usage 1 (Basic usage)</span>== | ==<span style="color:#000000;text-shadow:0.05em 0.05em 0.2em #00000099;">Usage 1 (Basic usage)</span>== | ||
*0. Don't forget to '''import DGS Head''' or use '''export.dgs:'''. | *0. Don't forget to '''import DGS Head''' or use "'''export.dgs:'''". | ||
*1. A '''Translation Table''' (Dictionary) should be specified: | *1. A '''Translation Table''' (Dictionary) should be specified: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
Line 30: | Line 30: | ||
==<span style="color:#000000;text-shadow:0.05em 0.05em 0.2em #00000099;">Usage 2 (Basic usage)</span>== | ==<span style="color:#000000;text-shadow:0.05em 0.05em 0.2em #00000099;">Usage 2 (Basic usage)</span>== | ||
*0. Don't forget to '''import DGS Head''' or use '''export.dgs:'''. | *0. Don't forget to '''import DGS Head''' or use "'''export.dgs:'''". | ||
*1. A '''Translation Table''' (Dictionary) should be specified: | *1. A '''Translation Table''' (Dictionary) should be specified: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
Line 56: | Line 56: | ||
==<span style="color:#000000;text-shadow:0.05em 0.05em 0.2em #00000099;">Usage 3 (With parameters)</span>== | ==<span style="color:#000000;text-shadow:0.05em 0.05em 0.2em #00000099;">Usage 3 (With parameters)</span>== | ||
*0. Don't forget to '''import DGS Head''' or use '''export.dgs:'''. | *0. Don't forget to '''import DGS Head''' or use "'''export.dgs:'''". | ||
*1. A '''Translation Table''' (Dictionary) should be specified. And here we have an extra '''%rep%''' that takes the place of '''parameter''': | *1. A '''Translation Table''' (Dictionary) should be specified. And here we have an extra '''%rep%''' that takes the place of '''parameter''': | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
Line 83: | Line 83: | ||
==<span style="color:#000000;text-shadow:0.05em 0.05em 0.2em #00000099;">Usage 4 (High Level Translation)</span>== | ==<span style="color:#000000;text-shadow:0.05em 0.05em 0.2em #00000099;">Usage 4 (High Level Translation)</span>== | ||
*0. Don't forget to '''import DGS Head''' or use '''export.dgs:'''. | *0. Don't forget to '''import DGS Head''' or use "'''export.dgs:'''". | ||
*1. A '''Translation Table''' (Dictionary) should be specified. And DGS parameter support 2nd level translation: | *1. A '''Translation Table''' (Dictionary) should be specified. And DGS parameter support 2nd level translation: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
Line 108: | Line 108: | ||
==<span style="color:#000000;text-shadow:0.05em 0.05em 0.2em #00000099;">Usage 5 (Language Change)</span>== | ==<span style="color:#000000;text-shadow:0.05em 0.05em 0.2em #00000099;">Usage 5 (Language Change)</span>== | ||
*0. Don't forget to '''import DGS Head''' or use '''export.dgs:'''. | *0. Don't forget to '''import DGS Head''' or use "'''export.dgs:'''". | ||
*1. A '''Translation Table''' (Dictionary) should be specified: | *1. A '''Translation Table''' (Dictionary) should be specified: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> |
Revision as of 06:29, 11 December 2020
Description
- 1. DGS has a built-in multilingual (multi-languae) system.
- 2. multilingual allows dynamic language changing and prevents non-essential GUI recreating or text reset by code.
- 3. DGS multilingual system will specify the structure of Translation Table (Dictionary).
Usage 1 (Basic usage)
- 0. Don't forget to import DGS Head or use "export.dgs:".
- 1. A Translation Table (Dictionary) should be specified:
Dict = { TestText1="Welcome To DGS", }
- 2. And, send the dictionary into DGS:
dgsSetTranslationTable("testDict",Dict) --Name,Dictionary.
- 3. Now, DGS knows that dictionary, we need to tell DGS we want to use it:
dgsSetAttachTranslation("testDict") --This is global setting to one resource
- 3. Create a label:
label = dgsCreateLabel (0.51, 0.54, 0.16, 0.14, {"TestText"}, true )
Usage 2 (Basic usage)
- 0. Don't forget to import DGS Head or use "export.dgs:".
- 1. A Translation Table (Dictionary) should be specified:
Dict = { TestText1="Welcome To DGS", }
- 2. And, send the dictionary into DGS:
dgsSetTranslationTable("testDict",Dict) --Name,Dictionary.
- 3. Now, DGS knows that dictionary, we can create a label and attach its text to the dictionary:
label = dgsCreateLabel (0.51, 0.54, 0.16, 0.14, {"TestText"}, true ) dgsAttachToTranslation(label,"testDict") --Only attach one element to the dictionary.
Or you can also do:
label = dgsCreateLabel (0.51, 0.54, 0.16, 0.14, "", true ) dgsAttachToTranslation(label,"testDict") --Only attach one element to the dictionary. dgsSetText(label,{"TestText"})
Usage 3 (With parameters)
- 0. Don't forget to import DGS Head or use "export.dgs:".
- 1. A Translation Table (Dictionary) should be specified. And here we have an extra %rep% that takes the place of parameter:
Dict = { TestText1="Welcome To %rep%", TestText2="Welcome To %rep% %rep%", }
- 2. And, send the dictionary into DGS:
dgsSetTranslationTable("testDict",Dict) --Name,Dictionary.
- 3. Now, DGS knows that dictionary, tell DGS we want to use it:
dgsSetAttachTranslation("testDict")
- 4. Create a label, pass "DGS" as the argument
label1 = dgsCreateLabel (0.51, 0.54, 0.16, 0.14, {"TestText1","DGS"}, true ) label2 = dgsCreateLabel (0.51, 0.64, 0.16, 0.14, {"TestText2","DGS",":D"}, true ) -- 2 parameters. label3 = dgsCreateLabel (0.51, 0.74, 0.16, 0.14, {"TestText2","DGS"}, true ) -- the rest unused '''%rep%''' will be deleted.
Usage 4 (High Level Translation)
- 0. Don't forget to import DGS Head or use "export.dgs:".
- 1. A Translation Table (Dictionary) should be specified. And DGS parameter support 2nd level translation:
Dict = { TestText="Welcome To %rep%. Have a good time %rep%", Smile=":)", }
- 2. And, send the dictionary into DGS:
dgsSetTranslationTable("testDict",Dict) --Name,Dictionary.
- 3. Now, DGS knows that dictionary, tell DGS we want to use it:
dgsSetAttachTranslation("testDict")
- 4. Create a label, and use 2nd translation:
label = dgsCreateLabel (0.51, 0.54, 0.16, 0.14, {"TestText","DGS", {"Smile"}}, true )
Usage 5 (Language Change)
- 0. Don't forget to import DGS Head or use "export.dgs:".
- 1. A Translation Table (Dictionary) should be specified:
Dict1 = { TestText="Welcome To DGS", } Dict2 = { TestText="SGD oT emocleW", }
- 2. And, send the dictionary into DGS:
dgsSetTranslationTable("testDict",Dict1) --Name,Dictionary.
- 3. Now, DGS knows that dictionary, tell DGS we want to use it:
dgsSetAttachTranslation("testDict")
- 4. Create a label:
label = dgsCreateLabel (0.51, 0.54, 0.16, 0.14, {"TestText"}, true )
- 4. Replace the dictionary (language changed), and you will see the text changed automatically:
dgsSetTranslationTable("testDict",Dict2)