Brought over the language strings from edunetworkbuilder and functions
for making language translation work.
This commit is contained in:
parent
0e9a6d1a15
commit
9be833dd2c
2606
Web/Resources/edustrings.en.json
Normal file
2606
Web/Resources/edustrings.en.json
Normal file
File diff suppressed because it is too large
Load Diff
2396
Web/Resources/edustrings.fr.json
Normal file
2396
Web/Resources/edustrings.fr.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -31,6 +31,7 @@
|
||||
<script src="selectmenu.js"></script>
|
||||
<script src="network.js"></script>
|
||||
<script src="textwindow.js"></script>
|
||||
<script src="language.js"></script>
|
||||
<script src="ui.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
3995
Web/language.js
Normal file
3995
Web/language.js
Normal file
File diff suppressed because it is too large
Load Diff
40
Web/scripts/BuildLanguage.pl
Normal file
40
Web/scripts/BuildLanguage.pl
Normal file
@ -0,0 +1,40 @@
|
||||
#!/usr/bin/perl
|
||||
opendir(Dir, "Resources") || die "Can't open Resources directory: $!\n";
|
||||
@files = grep(/edustrings/,readdir(Dir));
|
||||
closedir(Dir);
|
||||
|
||||
open ($outfile, '>', "language.js") or die $!;
|
||||
|
||||
print($outfile "language = {\n");
|
||||
foreach $file (@files) {
|
||||
$lang = $file;
|
||||
$lang =~ s/edustrings.//;
|
||||
$lang =~ s/.json//;
|
||||
print($outfile " $lang : {\n");
|
||||
|
||||
open my $info, "Resources/$file" or die "Could not open $file: $!";
|
||||
|
||||
while( my $line = <$info>) {
|
||||
chomp($line);
|
||||
if ( $line =~ /name": "(.*)",$/)
|
||||
{
|
||||
print($outfile " $1 : {");
|
||||
}
|
||||
if ( $line =~ /value": "(.*)",$/)
|
||||
{
|
||||
print($outfile "$line\n");
|
||||
}
|
||||
if ( $line =~ /value": "(.*)"$/) #if there is no comment
|
||||
{
|
||||
print($outfile "$line\n },\n");
|
||||
}
|
||||
if ( $line =~ /comment": "(.*)"$/)
|
||||
{
|
||||
print($outfile " $line\n },\n");
|
||||
}
|
||||
}
|
||||
print($outfile " },\n"); #End the language file;
|
||||
}
|
||||
print($outfile "];\n"); #End the language variable definition
|
||||
close($outfile);
|
||||
|
25
Web/scripts/ConvertResx2Json.sh
Normal file
25
Web/scripts/ConvertResx2Json.sh
Normal file
@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Convert the EduNetworkBuilder language files into json
|
||||
# Run this from the web directory, and make sure to have xq installed
|
||||
if which xq >/dev/null; then
|
||||
if [ -d Resources -a -d EduResources/languages ]; then
|
||||
for a in EduResources/languages/*.resx; do
|
||||
c=$a;
|
||||
if [ $a = "EduResources/languages/edustrings.resx" ]; then
|
||||
c="edustrings.en.resx"
|
||||
fi
|
||||
b=$(basename $c | sed 's/.resx/\.json/');
|
||||
#if [ ! -e Resources/languages/$b ]; then
|
||||
echo $b
|
||||
xq '.root.data' $a |sed 's/\@name/name/' | grep -v 'xml:space' > Resources/$b
|
||||
#fi
|
||||
done
|
||||
else
|
||||
echo "You must be in the web directory of the EduNetworkBuilder git repo for this to work"
|
||||
fi
|
||||
else
|
||||
echo "xq must be installed. This comes with the jq program"
|
||||
echo "jq is used for working with json files and xq is the counterpart"
|
||||
echo "that converts xml to json."
|
||||
fi
|
24
Web/ui.js
24
Web/ui.js
@ -16,6 +16,7 @@ var ui_HadHighlight = false;
|
||||
var ui_status_height = 25;
|
||||
var ui_StatusText = "";
|
||||
var ui_HighlightArray = [];
|
||||
var translator = new Language('en');
|
||||
|
||||
//The user interface mode. 0=network, 1=network information, 2=puzzle-selection menu
|
||||
var uiMode=1;
|
||||
@ -828,3 +829,26 @@ function device_clickOn(point, actionrec) {
|
||||
PrintScreen();
|
||||
}
|
||||
}
|
||||
|
||||
function Language(lang) {
|
||||
var __construct = function () {
|
||||
if (eval('typeof ' + lang) == 'undefined') {
|
||||
lang = "en";
|
||||
}
|
||||
ui_language = 'language.' + lang;
|
||||
return;
|
||||
}()
|
||||
|
||||
this.getStr = function (str, defaultStr) {
|
||||
var retStr = eval('eval(ui_language).' + str);
|
||||
if (typeof retStr != 'undefined') {
|
||||
return retStr;
|
||||
} else {
|
||||
if (typeof defaultStr != 'undefined') {
|
||||
return defaultStr;
|
||||
} else {
|
||||
return eval('ui_language.' + str);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user