[imp] setup i18n
bzr revid: nicolas.vanhoren@openerp.com-20110811163933-lcs6zv2e3kn8b09j
This commit is contained in:
parent
6322a565f5
commit
bd95f542ad
|
@ -18,6 +18,7 @@ import openerpweb
|
|||
import openerpweb.ast
|
||||
import openerpweb.nonliterals
|
||||
|
||||
from babel.messages.pofile import read_po
|
||||
|
||||
# Should move to openerpweb.Xml2Json
|
||||
class Xml2Json:
|
||||
|
@ -156,6 +157,21 @@ class WebClient(openerpweb.Controller):
|
|||
'css': css
|
||||
}
|
||||
return r
|
||||
|
||||
@openerpweb.jsonrequest
|
||||
def translations(self, addon_name, lang):
|
||||
f_name = os.path.join(openerpweb.path_addons, addon_name, "po", lang + ".po")
|
||||
with open(f_name) as t_file:
|
||||
po = read_po(t_file)
|
||||
|
||||
transl = {"messages":[]}
|
||||
|
||||
for x in po:
|
||||
if x.id:
|
||||
transl["messages"].append({'id': x.id, 'string': x.string})
|
||||
|
||||
return transl
|
||||
|
||||
|
||||
class Database(openerpweb.Controller):
|
||||
_cp_path = "/base/database"
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
# Translations template for PROJECT.
|
||||
# Copyright (C) 2011 ORGANIZATION
|
||||
# This file is distributed under the same license as the PROJECT project.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, 2011.
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PROJECT VERSION\n"
|
||||
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
|
||||
"POT-Creation-Date: 2011-08-09 17:30+0200\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=utf-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Generated-By: Babel 0.9.4\n"
|
||||
|
||||
#: addons/base/static/src/js/core.js:11
|
||||
msgid "I am a sweet chicken."
|
||||
msgstr ""
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
# Translations template for PROJECT.
|
||||
# Copyright (C) 2011 ORGANIZATION
|
||||
# This file is distributed under the same license as the PROJECT project.
|
||||
# niv <nicolas.vanhoren@openerp.com>, 2011.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PROJECT VERSION\n"
|
||||
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
|
||||
"POT-Creation-Date: 2011-08-09 17:30+0200\n"
|
||||
"PO-Revision-Date: 2011-08-09 17:31+0200\n"
|
||||
"Last-Translator: niv <nicolas.vanhoren@openerp.com>\n"
|
||||
"Language-Team: French\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Generated-By: Babel 0.9.4\n"
|
||||
"Language: fr\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||
|
||||
#: addons/base/static/src/js/core.js:11
|
||||
msgid "I am a sweet chicken."
|
||||
msgstr "Je suis un gentil poulet."
|
|
@ -0,0 +1,13 @@
|
|||
## Extraction from Python source files
|
||||
#[python: **.py]
|
||||
## Extraction from Genshi HTML and text templates
|
||||
#[genshi: **/templates/**.html]
|
||||
#ignore_tags = script,style
|
||||
#include_attrs = alt title summary
|
||||
#[genshi: **/templates/**.txt]
|
||||
#template_class = genshi.template:TextTemplate
|
||||
#encoding = ISO-8819-15
|
||||
## Extraction from JavaScript files
|
||||
[javascript: **.js]
|
||||
[javascript: **.xml]
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
#!/bin/sh
|
||||
|
||||
usage()
|
||||
{
|
||||
cat << EOF
|
||||
usage: $0 -a
|
||||
usage: $0 DIR OUTPUT_FILE
|
||||
|
||||
OPTIONS:
|
||||
-a recreate the .pot file for all addons
|
||||
-h print this message
|
||||
EOF
|
||||
exit 0
|
||||
}
|
||||
|
||||
do_all=
|
||||
|
||||
while getopts "a" opt
|
||||
do
|
||||
case "$opt" in
|
||||
a)
|
||||
do_all=true;;
|
||||
h)
|
||||
usage;;
|
||||
\?)
|
||||
usage;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $((OPTIND-1))
|
||||
|
||||
if [ -n "$do_all" ]
|
||||
then
|
||||
echo "Extracting all the translations"
|
||||
$0 addons/base/static/src/ addons/base/po/base.pot
|
||||
elif [ -n "$2" ]
|
||||
then
|
||||
pybabel extract -F babel.cfg -o $2 -k _t --no-default-keywords $1
|
||||
else
|
||||
usage
|
||||
fi
|
Loading…
Reference in New Issue