localized files as read in and printed back out, unmodifed but for how

python prints them differently.  This is a baseline: modifications
will follow.
This commit is contained in:
Eric House 2014-04-11 22:43:56 -07:00
parent 258b81dfb5
commit 77b87c6458
5 changed files with 59 additions and 12 deletions

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version='1.0' encoding='utf-8'?>
<!-- Copyright (C) 2007 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
@ -13,7 +13,6 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<resources>
<string name="button_new_game">Afegeix una partida</string>
@ -65,7 +64,7 @@
<string name="strs_values_header">%s quantitat/valors:\n</string>
<string name="strd_remaining_tiles_add">+ %d [fitxes romanents]</string>
<string name="strd_unused_tiles_sub">- %d [fitxes al faristol]</string>
<string name="strd_time_penalty_sub"></string>
<string name="strd_time_penalty_sub"/>
<string name="str_pass"> - %d [temps]</string>
<string name="strs_move_across">mou (des de %s horitzontal)</string>
<string name="strs_move_down">mou (des de %s avall)</string>
@ -75,7 +74,7 @@
<string name="strd_cumulative_score">Puntuació acumulada: %d</string>
<string name="strs_new_tiles">Fitxes noves: %s</string>
<string name="str_passed">Ha passat</string>
<string name="strsd_summaryscored"></string>
<string name="strsd_summaryscored"/>
<string name="str_lostturn">Torn perdut</string>
<string name="str_commit_confirm">Voleu fer la jugada?\n</string>
<string name="str_bonus_all">Bonificació per usar totes les fitxes: 50\n</string>

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version='1.0' encoding='utf-8'?>
<!-- Copyright (C) 2007 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
@ -13,7 +13,6 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<resources>
<string name="button_new_game">Přidat hru</string>
@ -64,7 +63,7 @@
<string name="strs_values_header">%s počet/hodnota:\n</string>
<string name="strd_remaining_tiles_add">+ %d [všechny zbývající kameny]</string>
<string name="strd_unused_tiles_sub">- %d [nepoužité kameny]</string>
<string name="strd_time_penalty_sub"></string>
<string name="strd_time_penalty_sub"/>
<string name="str_pass"> - %d [čas]</string>
<string name="strs_move_across">tah (od %s napříč)</string>
<string name="strs_move_down">tah (od %s dolů)</string>

View file

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version='1.0' encoding='utf-8'?>
<!-- -*- compile-command: "cd ../../; ant install"; -*- -->
<resources>
<!-- The name of the app. Not localized! -->
<string name="app_name">Crosswords</string>
@ -708,7 +707,7 @@
<string name="str_remote_movedf">Jogador remoto %1$s fez esta
jogada:\u0020</string>
<!-- I don't know how this is used. :-) -->
<string name="strd_time_penalty_sub"></string>
<string name="strd_time_penalty_sub"/>
<!-- Used in formatting game history and move summaries -->
<string name="str_pass"> - %d [tempo]</string>
<!-- Used in formatting game history and move summaries -->
@ -2079,7 +2078,7 @@
<!-- -->
<string name="warn_sms_disabled">Jogar por SMS está desabilitado
atualmente, então nenhuma jogada será enviada para esse jogo. (Se
você quiser habilitar jogos por SMS, vá para Configurações->Rede.)
você quiser habilitar jogos por SMS, vá para Configurações-&gt;Rede.)
</string>
<!-- -->

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version='1.0' encoding='utf-8'?>
<!-- Copyright (C) 2007 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");

View file

@ -0,0 +1,50 @@
#!/usr/bin/python
import mk_xml, os, sys, codecs
from lxml import etree
def longestCommon( name, pairs ):
match = None
for ii in range(1, len(name)):
str = name[:ii]
for key in pairs.keys():
if str == key[:ii]:
print str, "matches", key, "so far"
match = str
break
sys.exit(0)
def checkAgainst( path, pairs ):
print "looking at", path
doc = etree.parse( path )
root = doc.getroot();
# for child in root.iter():
# if child.tag == "string":
# name = child.get("name")
# if not name in pairs:
# longestCommon( name, pairs )
# try = tryNames( name, pairs )
# response = raw_input( "unknown name: %s; respond:" % (name) )
# print "you wrote:", response
# Now walk the doc, comparing names with the set in pairs and
# enforcing rules about names, offering to change whereever
# possible
out = open( path, "w" )
out.write( etree.tostring( doc, pretty_print=True, encoding="utf-8", xml_declaration=True ) )
def main():
pairs = mk_xml.getStrings()
for subdir, dirs, files in os.walk('res_src'):
for file in [file for file in files if file == "strings.xml"]:
path = "%s/%s" % (subdir, file)
checkAgainst( path, pairs )
##############################################################################
if __name__ == '__main__':
main()