File: translation.inc

package info (click to toggle)
stellarium 0.10.5-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 57,884 kB
  • ctags: 26,597
  • sloc: ansic: 347,123; cpp: 56,161; perl: 995; python: 427; sh: 151; pascal: 140; sql: 131; makefile: 2
file content (65 lines) | stat: -rw-r--r-- 1,659 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//
// Name:        Provide simple translation option for scripts
// License:     Public Domain
// Author:      Matthew Gates
// Description: Simple translation functions for scripts.
//              set translations with the setTr function, then use tr(string)
//		everywhere in your script where you want to get a translated
//		string.  The current application language is taken from the
//		Application Language setting.   See core.setAppLanguage and
//              core.getAppLanguage for details.
//

// declare a global variable to store saved state
var translationStrings = new Array();

// call this function with some string ID
function tr(str)
{
	lang = core.getAppLanguage();
	// core.debug("tr: getting " + lang + " translation for " + str);
	if (translationStrings[lang]==undefined) 
	{ 	
		// core.debug("tr: no lang array");
		return str; 
	}
	else if (translationStrings[lang][str]==undefined) 
	{ 
		// core.debug("tr: no phrase array");
		return str; 
	}
	else 
	{ 
		// core.debug("tr: got it");
		return translationStrings[lang][str]; 
	}
}

function setTr(lang, original, translation)
{
	// core.debug("setTr: " + lang + ", " + original + ", " + translation);
	if (translationStrings[lang]==undefined)
	{
		// core.debug("setTr: making new lang array");
		translationStrings[lang] = new Array();
	}

	translationStrings[lang][original] = translation;

}

function dumpTr() 
{
	core.debug("We have the following translations:");
	for (lang in translationStrings)
	{
		core.debug("Language: " + lang);
		strings = translationStrings[lang];
		for (phrase in strings)
		{
			core.debug(" - " + phrase + " -> " + strings[phrase]);
		}
	}

}