mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-17 22:23:10 +03:00
Merge pull request #1235 from sgk/i18nResourcesRearrange
Rearrange i18n Resource files into a directory
This commit is contained in:
@ -34,7 +34,7 @@ public class I18n {
|
|||||||
if (language != null && language.trim().length() > 0) {
|
if (language != null && language.trim().length() > 0) {
|
||||||
Locale.setDefault(new Locale(language));
|
Locale.setDefault(new Locale(language));
|
||||||
}
|
}
|
||||||
i18n = ResourceBundle.getBundle("processing.app.Resources", Locale.getDefault());
|
i18n = ResourceBundle.getBundle("processing.app.i18n.Resources", Locale.getDefault());
|
||||||
|
|
||||||
PROMPT_YES = _("Yes");
|
PROMPT_YES = _("Yes");
|
||||||
PROMPT_NO = _("No");
|
PROMPT_NO = _("No");
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -30,11 +30,11 @@ def read_po(fp):
|
|||||||
rvalue += line
|
rvalue += line
|
||||||
elif line.startswith('msgid '):
|
elif line.startswith('msgid '):
|
||||||
st = 1
|
st = 1
|
||||||
key = unquote(line[5:])
|
key = unquote(line[6:])
|
||||||
rkey = line
|
rkey = line
|
||||||
elif line.startswith('msgstr '):
|
elif line.startswith('msgstr '):
|
||||||
st = 2
|
st = 2
|
||||||
value = unquote(line[6:])
|
value = unquote(line[7:])
|
||||||
rvalue = line
|
rvalue = line
|
||||||
else:
|
else:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
@ -45,34 +45,29 @@ def read_po(fp):
|
|||||||
def main():
|
def main():
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
# Read the current text catalog.
|
# Read the new text catalog template.
|
||||||
d = {}
|
d = {}
|
||||||
firstcomment = ''
|
for (comment, key, value, rkey, rvalue) in read_po(sys.stdin):
|
||||||
it = read_po(file(sys.argv[1]))
|
d[key] = (comment, rkey, rvalue)
|
||||||
try:
|
|
||||||
(comment, key, value, rkey, rvalue) = it.next()
|
# Override existing entries with current text catalog.
|
||||||
d[key] = rvalue
|
for (comment, key, value, rkey, rvalue) in read_po(file(sys.argv[1])):
|
||||||
firstcomment = comment # Preserve the first comment block
|
if d.has_key(key):
|
||||||
except StopIteration:
|
d[key] = (comment, rkey, rvalue)
|
||||||
pass
|
|
||||||
for (comment, key, value, rkey, rvalue) in it:
|
|
||||||
d[key] = rvalue
|
|
||||||
|
|
||||||
# Read the new text catalog template and output.
|
|
||||||
# The translated values come from the current text catalog read above.
|
|
||||||
out = file(sys.argv[1], 'w')
|
out = file(sys.argv[1], 'w')
|
||||||
out.write(firstcomment)
|
if d.has_key(''):
|
||||||
it = read_po(sys.stdin)
|
(comment, rkey, rvalue) = d['']
|
||||||
try:
|
|
||||||
(comment, key, value, rkey, rvalue) = it.next()
|
|
||||||
out.write(rkey)
|
|
||||||
out.write(d.get(key, rvalue))
|
|
||||||
except StopIteration:
|
|
||||||
pass
|
|
||||||
for (comment, key, value, rkey, rvalue) in it:
|
|
||||||
out.write(comment)
|
out.write(comment)
|
||||||
out.write(rkey)
|
out.write(rkey)
|
||||||
out.write(d.get(key, rvalue))
|
out.write(rvalue)
|
||||||
|
del d['']
|
||||||
|
|
||||||
|
for key in sorted(d.keys()):
|
||||||
|
(comment, rkey, rvalue) = d[key]
|
||||||
|
out.write(comment)
|
||||||
|
out.write(rkey)
|
||||||
|
out.write(rvalue)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
@ -1,4 +1,4 @@
|
|||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# Extract the text catalog from the source code,
|
# Extract the text catalog from the source code,
|
||||||
@ -18,14 +18,25 @@ trap "rm -f '$catalog' '$files'" 0 1 2 15
|
|||||||
|
|
||||||
# Generate the new text catalog without the already translated texts.
|
# Generate the new text catalog without the already translated texts.
|
||||||
# The 'merge existing' option for xgetext does not work propery for our purpose.
|
# The 'merge existing' option for xgetext does not work propery for our purpose.
|
||||||
find . -name '*.java' -print > "$files"
|
find .. -name '*.java' -print > "$files"
|
||||||
xgettext -L Java --from-code=utf-8 -k_ --output="$catalog" --files-from="$files"
|
xgettext -L Java --from-code=utf-8 -k_ --output="$catalog" --files-from="$files"
|
||||||
|
|
||||||
# Then, merge with already translated texts.
|
update()
|
||||||
for target in *.po; do
|
{
|
||||||
echo "Updating $target..."
|
echo "Updating $1..."
|
||||||
cat "$catalog" | python i18n_update.py "$target"
|
cat "$catalog" | python i18n_update.py "$1"
|
||||||
msgcat -p "$target" > $(basename "$target" .po).properties
|
msgcat -p "$1" > $(basename "$1" .po).properties
|
||||||
# msgcat may complain about "CHARSET" if you didn't replace "CHARSET" with
|
# msgcat may complain about "CHARSET" if you didn't replace "CHARSET" with
|
||||||
# your correct charset.
|
# your correct charset.
|
||||||
done
|
}
|
||||||
|
|
||||||
|
# Then, merge with already translated texts.
|
||||||
|
if [ $# = 0 ]; then
|
||||||
|
for target in *.po; do
|
||||||
|
update $target
|
||||||
|
done
|
||||||
|
else
|
||||||
|
for target in $*; do
|
||||||
|
update Resources_$target.po
|
||||||
|
done
|
||||||
|
fi
|
Reference in New Issue
Block a user