2011-12-05 10:50:28 +00:00
|
|
|
#!/usr/bin/env python
|
2011-08-16 10:09:40 +00:00
|
|
|
# EASY-INSTALL-ENTRY-SCRIPT: 'Babel==0.9.6','console_scripts','pybabel'
|
|
|
|
__requires__ = 'Babel==0.9.6'
|
|
|
|
import sys
|
|
|
|
from pkg_resources import load_entry_point
|
2011-08-16 10:42:19 +00:00
|
|
|
import re
|
2011-08-16 11:34:00 +00:00
|
|
|
import json
|
[IMP] refactored translation system to merge web translations with addons translations
- Moved the web *.po files to /i18n to be consistent
with the addons convention. Using /po was considered
for a while because it played better with LP's auto-
detection of PO Templates, but that is not necessary
anymore, we now have full control on LP templates.
- In order to support addons that contain translations
for both the web addon and the regular addon part,
both kinds of translations are now merged in a single
addon/i18n/addon.pot file. Terms that are used by
the web part are now marked with a PO annotation:
#. openerp-web
so the web client can recognize them and only load
the relevant translations in the browser memory.
This is important because a complete PO file can
be rather large, e.g. account/i18n/de.po = 400KB.
- The web translation export scripts were updated to
behave properly for addons that have a non-web
part, and will merge the web translation in the
original POT file, annotating the web translations
as needed. These scripts are Unix-only and meant
to be used by OpenERP packagers when needed.
- The GetText spec says that PO auto-comments indicating
the source location have this form:
#: /path/to/file:lineno
However OpenERP's POT export system defaults to a modified
version of this format with an extra 'type' field:
#: type:/path/to/file:lineno
The babel extractors we use have the GetText format
hardcoded so a small patch is needed on the server
to make it more lenient and accept the standard
source annotation, defaulting to 'code' type.
This does not matter for openerp-web, but makes sure
the server will not fail to load the new PO files
that contain openerp-web translations with standard
annotations.
The patch for making the server more lenient was
checked in trunk at revision 4002
rev-id odo@openerp.com-20120202143210-05p1w24t6u77cyv8
- The existing translation sync and export wizards for
regular addons have not been updated to consider
web addons, so for the time being we will have
to export regular addons terms first, and run the
web export script (gen_translations.sh) on the
addons directory afterwards. This could be improved
later.
As soon as this change is merged we will have to
perform a full update of addons translation
templates in order to include the web terms as well.
bzr revid: odo@openerp.com-20120202145603-ffo0il0qnfp3r6gt
2012-02-02 14:56:03 +00:00
|
|
|
from lxml import etree as elt
|
|
|
|
from babel.messages import extract
|
2011-08-16 10:09:40 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
sys.exit(
|
|
|
|
load_entry_point('Babel==0.9.6', 'console_scripts', 'pybabel')()
|
|
|
|
)
|
[IMP] refactored translation system to merge web translations with addons translations
- Moved the web *.po files to /i18n to be consistent
with the addons convention. Using /po was considered
for a while because it played better with LP's auto-
detection of PO Templates, but that is not necessary
anymore, we now have full control on LP templates.
- In order to support addons that contain translations
for both the web addon and the regular addon part,
both kinds of translations are now merged in a single
addon/i18n/addon.pot file. Terms that are used by
the web part are now marked with a PO annotation:
#. openerp-web
so the web client can recognize them and only load
the relevant translations in the browser memory.
This is important because a complete PO file can
be rather large, e.g. account/i18n/de.po = 400KB.
- The web translation export scripts were updated to
behave properly for addons that have a non-web
part, and will merge the web translation in the
original POT file, annotating the web translations
as needed. These scripts are Unix-only and meant
to be used by OpenERP packagers when needed.
- The GetText spec says that PO auto-comments indicating
the source location have this form:
#: /path/to/file:lineno
However OpenERP's POT export system defaults to a modified
version of this format with an extra 'type' field:
#: type:/path/to/file:lineno
The babel extractors we use have the GetText format
hardcoded so a small patch is needed on the server
to make it more lenient and accept the standard
source annotation, defaulting to 'code' type.
This does not matter for openerp-web, but makes sure
the server will not fail to load the new PO files
that contain openerp-web translations with standard
annotations.
The patch for making the server more lenient was
checked in trunk at revision 4002
rev-id odo@openerp.com-20120202143210-05p1w24t6u77cyv8
- The existing translation sync and export wizards for
regular addons have not been updated to consider
web addons, so for the time being we will have
to export regular addons terms first, and run the
web export script (gen_translations.sh) on the
addons directory afterwards. This could be improved
later.
As soon as this change is merged we will have to
perform a full update of addons translation
templates in order to include the web terms as well.
bzr revid: odo@openerp.com-20120202145603-ffo0il0qnfp3r6gt
2012-02-02 14:56:03 +00:00
|
|
|
|
2011-08-17 11:28:28 +00:00
|
|
|
XMLJS_EXPR = re.compile(r"""(?:\_t *\( *((?:"(?:[^"\\]|\\.)*")|(?:'(?:[^'\\]|\\.)*')) *\))""")
|
|
|
|
|
[IMP] refactored translation system to merge web translations with addons translations
- Moved the web *.po files to /i18n to be consistent
with the addons convention. Using /po was considered
for a while because it played better with LP's auto-
detection of PO Templates, but that is not necessary
anymore, we now have full control on LP templates.
- In order to support addons that contain translations
for both the web addon and the regular addon part,
both kinds of translations are now merged in a single
addon/i18n/addon.pot file. Terms that are used by
the web part are now marked with a PO annotation:
#. openerp-web
so the web client can recognize them and only load
the relevant translations in the browser memory.
This is important because a complete PO file can
be rather large, e.g. account/i18n/de.po = 400KB.
- The web translation export scripts were updated to
behave properly for addons that have a non-web
part, and will merge the web translation in the
original POT file, annotating the web translations
as needed. These scripts are Unix-only and meant
to be used by OpenERP packagers when needed.
- The GetText spec says that PO auto-comments indicating
the source location have this form:
#: /path/to/file:lineno
However OpenERP's POT export system defaults to a modified
version of this format with an extra 'type' field:
#: type:/path/to/file:lineno
The babel extractors we use have the GetText format
hardcoded so a small patch is needed on the server
to make it more lenient and accept the standard
source annotation, defaulting to 'code' type.
This does not matter for openerp-web, but makes sure
the server will not fail to load the new PO files
that contain openerp-web translations with standard
annotations.
The patch for making the server more lenient was
checked in trunk at revision 4002
rev-id odo@openerp.com-20120202143210-05p1w24t6u77cyv8
- The existing translation sync and export wizards for
regular addons have not been updated to consider
web addons, so for the time being we will have
to export regular addons terms first, and run the
web export script (gen_translations.sh) on the
addons directory afterwards. This could be improved
later.
As soon as this change is merged we will have to
perform a full update of addons translation
templates in order to include the web terms as well.
bzr revid: odo@openerp.com-20120202145603-ffo0il0qnfp3r6gt
2012-02-02 14:56:03 +00:00
|
|
|
TRANSLATION_FLAG_COMMENT = "openerp-web"
|
|
|
|
|
2011-08-17 11:28:28 +00:00
|
|
|
def extract_xmljs(fileobj, keywords, comment_tags, options):
|
[IMP] refactored translation system to merge web translations with addons translations
- Moved the web *.po files to /i18n to be consistent
with the addons convention. Using /po was considered
for a while because it played better with LP's auto-
detection of PO Templates, but that is not necessary
anymore, we now have full control on LP templates.
- In order to support addons that contain translations
for both the web addon and the regular addon part,
both kinds of translations are now merged in a single
addon/i18n/addon.pot file. Terms that are used by
the web part are now marked with a PO annotation:
#. openerp-web
so the web client can recognize them and only load
the relevant translations in the browser memory.
This is important because a complete PO file can
be rather large, e.g. account/i18n/de.po = 400KB.
- The web translation export scripts were updated to
behave properly for addons that have a non-web
part, and will merge the web translation in the
original POT file, annotating the web translations
as needed. These scripts are Unix-only and meant
to be used by OpenERP packagers when needed.
- The GetText spec says that PO auto-comments indicating
the source location have this form:
#: /path/to/file:lineno
However OpenERP's POT export system defaults to a modified
version of this format with an extra 'type' field:
#: type:/path/to/file:lineno
The babel extractors we use have the GetText format
hardcoded so a small patch is needed on the server
to make it more lenient and accept the standard
source annotation, defaulting to 'code' type.
This does not matter for openerp-web, but makes sure
the server will not fail to load the new PO files
that contain openerp-web translations with standard
annotations.
The patch for making the server more lenient was
checked in trunk at revision 4002
rev-id odo@openerp.com-20120202143210-05p1w24t6u77cyv8
- The existing translation sync and export wizards for
regular addons have not been updated to consider
web addons, so for the time being we will have
to export regular addons terms first, and run the
web export script (gen_translations.sh) on the
addons directory afterwards. This could be improved
later.
As soon as this change is merged we will have to
perform a full update of addons translation
templates in order to include the web terms as well.
bzr revid: odo@openerp.com-20120202145603-ffo0il0qnfp3r6gt
2012-02-02 14:56:03 +00:00
|
|
|
"""Extract messages from Javascript code embedded into XML documents.
|
|
|
|
This complements the ``extract_javascript`` extractor which works
|
|
|
|
only on pure .js files, and the``extract_qweb`` extractor, which only
|
|
|
|
extracts XML text.
|
|
|
|
|
|
|
|
:param fileobj: the file-like object the messages should be extracted
|
|
|
|
from
|
|
|
|
:param keywords: a list of keywords (i.e. function names) that should
|
|
|
|
be recognized as translation functions
|
|
|
|
:param comment_tags: a list of translator tags to search for and
|
|
|
|
include in the results
|
|
|
|
:param options: a dictionary of additional options (optional)
|
|
|
|
:return: an iterator over ``(lineno, funcname, message, comments)``
|
|
|
|
tuples
|
|
|
|
:rtype: ``iterator``
|
|
|
|
"""
|
2011-08-17 11:28:28 +00:00
|
|
|
content = fileobj.read()
|
|
|
|
found = XMLJS_EXPR.finditer(content)
|
|
|
|
index = 0
|
|
|
|
line_nbr = 0
|
|
|
|
for f in found:
|
[IMP] refactored translation system to merge web translations with addons translations
- Moved the web *.po files to /i18n to be consistent
with the addons convention. Using /po was considered
for a while because it played better with LP's auto-
detection of PO Templates, but that is not necessary
anymore, we now have full control on LP templates.
- In order to support addons that contain translations
for both the web addon and the regular addon part,
both kinds of translations are now merged in a single
addon/i18n/addon.pot file. Terms that are used by
the web part are now marked with a PO annotation:
#. openerp-web
so the web client can recognize them and only load
the relevant translations in the browser memory.
This is important because a complete PO file can
be rather large, e.g. account/i18n/de.po = 400KB.
- The web translation export scripts were updated to
behave properly for addons that have a non-web
part, and will merge the web translation in the
original POT file, annotating the web translations
as needed. These scripts are Unix-only and meant
to be used by OpenERP packagers when needed.
- The GetText spec says that PO auto-comments indicating
the source location have this form:
#: /path/to/file:lineno
However OpenERP's POT export system defaults to a modified
version of this format with an extra 'type' field:
#: type:/path/to/file:lineno
The babel extractors we use have the GetText format
hardcoded so a small patch is needed on the server
to make it more lenient and accept the standard
source annotation, defaulting to 'code' type.
This does not matter for openerp-web, but makes sure
the server will not fail to load the new PO files
that contain openerp-web translations with standard
annotations.
The patch for making the server more lenient was
checked in trunk at revision 4002
rev-id odo@openerp.com-20120202143210-05p1w24t6u77cyv8
- The existing translation sync and export wizards for
regular addons have not been updated to consider
web addons, so for the time being we will have
to export regular addons terms first, and run the
web export script (gen_translations.sh) on the
addons directory afterwards. This could be improved
later.
As soon as this change is merged we will have to
perform a full update of addons translation
templates in order to include the web terms as well.
bzr revid: odo@openerp.com-20120202145603-ffo0il0qnfp3r6gt
2012-02-02 14:56:03 +00:00
|
|
|
msg = f.group(1)
|
|
|
|
msg = json.loads(msg)
|
2011-08-17 11:28:28 +00:00
|
|
|
while index < f.start():
|
|
|
|
if content[index] == "\n":
|
|
|
|
line_nbr += 1
|
|
|
|
index += 1
|
[IMP] refactored translation system to merge web translations with addons translations
- Moved the web *.po files to /i18n to be consistent
with the addons convention. Using /po was considered
for a while because it played better with LP's auto-
detection of PO Templates, but that is not necessary
anymore, we now have full control on LP templates.
- In order to support addons that contain translations
for both the web addon and the regular addon part,
both kinds of translations are now merged in a single
addon/i18n/addon.pot file. Terms that are used by
the web part are now marked with a PO annotation:
#. openerp-web
so the web client can recognize them and only load
the relevant translations in the browser memory.
This is important because a complete PO file can
be rather large, e.g. account/i18n/de.po = 400KB.
- The web translation export scripts were updated to
behave properly for addons that have a non-web
part, and will merge the web translation in the
original POT file, annotating the web translations
as needed. These scripts are Unix-only and meant
to be used by OpenERP packagers when needed.
- The GetText spec says that PO auto-comments indicating
the source location have this form:
#: /path/to/file:lineno
However OpenERP's POT export system defaults to a modified
version of this format with an extra 'type' field:
#: type:/path/to/file:lineno
The babel extractors we use have the GetText format
hardcoded so a small patch is needed on the server
to make it more lenient and accept the standard
source annotation, defaulting to 'code' type.
This does not matter for openerp-web, but makes sure
the server will not fail to load the new PO files
that contain openerp-web translations with standard
annotations.
The patch for making the server more lenient was
checked in trunk at revision 4002
rev-id odo@openerp.com-20120202143210-05p1w24t6u77cyv8
- The existing translation sync and export wizards for
regular addons have not been updated to consider
web addons, so for the time being we will have
to export regular addons terms first, and run the
web export script (gen_translations.sh) on the
addons directory afterwards. This could be improved
later.
As soon as this change is merged we will have to
perform a full update of addons translation
templates in order to include the web terms as well.
bzr revid: odo@openerp.com-20120202145603-ffo0il0qnfp3r6gt
2012-02-02 14:56:03 +00:00
|
|
|
yield (line_nbr, None, msg, [TRANSLATION_FLAG_COMMENT])
|
2011-08-16 11:34:00 +00:00
|
|
|
|
2011-08-16 10:09:40 +00:00
|
|
|
def extract_qweb(fileobj, keywords, comment_tags, options):
|
[IMP] refactored translation system to merge web translations with addons translations
- Moved the web *.po files to /i18n to be consistent
with the addons convention. Using /po was considered
for a while because it played better with LP's auto-
detection of PO Templates, but that is not necessary
anymore, we now have full control on LP templates.
- In order to support addons that contain translations
for both the web addon and the regular addon part,
both kinds of translations are now merged in a single
addon/i18n/addon.pot file. Terms that are used by
the web part are now marked with a PO annotation:
#. openerp-web
so the web client can recognize them and only load
the relevant translations in the browser memory.
This is important because a complete PO file can
be rather large, e.g. account/i18n/de.po = 400KB.
- The web translation export scripts were updated to
behave properly for addons that have a non-web
part, and will merge the web translation in the
original POT file, annotating the web translations
as needed. These scripts are Unix-only and meant
to be used by OpenERP packagers when needed.
- The GetText spec says that PO auto-comments indicating
the source location have this form:
#: /path/to/file:lineno
However OpenERP's POT export system defaults to a modified
version of this format with an extra 'type' field:
#: type:/path/to/file:lineno
The babel extractors we use have the GetText format
hardcoded so a small patch is needed on the server
to make it more lenient and accept the standard
source annotation, defaulting to 'code' type.
This does not matter for openerp-web, but makes sure
the server will not fail to load the new PO files
that contain openerp-web translations with standard
annotations.
The patch for making the server more lenient was
checked in trunk at revision 4002
rev-id odo@openerp.com-20120202143210-05p1w24t6u77cyv8
- The existing translation sync and export wizards for
regular addons have not been updated to consider
web addons, so for the time being we will have
to export regular addons terms first, and run the
web export script (gen_translations.sh) on the
addons directory afterwards. This could be improved
later.
As soon as this change is merged we will have to
perform a full update of addons translation
templates in order to include the web terms as well.
bzr revid: odo@openerp.com-20120202145603-ffo0il0qnfp3r6gt
2012-02-02 14:56:03 +00:00
|
|
|
"""Extract messages from qweb template files.
|
2011-08-16 10:09:40 +00:00
|
|
|
:param fileobj: the file-like object the messages should be extracted
|
|
|
|
from
|
|
|
|
:param keywords: a list of keywords (i.e. function names) that should
|
|
|
|
be recognized as translation functions
|
|
|
|
:param comment_tags: a list of translator tags to search for and
|
|
|
|
include in the results
|
|
|
|
:param options: a dictionary of additional options (optional)
|
|
|
|
:return: an iterator over ``(lineno, funcname, message, comments)``
|
|
|
|
tuples
|
|
|
|
:rtype: ``iterator``
|
|
|
|
"""
|
2011-08-16 10:42:19 +00:00
|
|
|
result = []
|
[IMP] refactored translation system to merge web translations with addons translations
- Moved the web *.po files to /i18n to be consistent
with the addons convention. Using /po was considered
for a while because it played better with LP's auto-
detection of PO Templates, but that is not necessary
anymore, we now have full control on LP templates.
- In order to support addons that contain translations
for both the web addon and the regular addon part,
both kinds of translations are now merged in a single
addon/i18n/addon.pot file. Terms that are used by
the web part are now marked with a PO annotation:
#. openerp-web
so the web client can recognize them and only load
the relevant translations in the browser memory.
This is important because a complete PO file can
be rather large, e.g. account/i18n/de.po = 400KB.
- The web translation export scripts were updated to
behave properly for addons that have a non-web
part, and will merge the web translation in the
original POT file, annotating the web translations
as needed. These scripts are Unix-only and meant
to be used by OpenERP packagers when needed.
- The GetText spec says that PO auto-comments indicating
the source location have this form:
#: /path/to/file:lineno
However OpenERP's POT export system defaults to a modified
version of this format with an extra 'type' field:
#: type:/path/to/file:lineno
The babel extractors we use have the GetText format
hardcoded so a small patch is needed on the server
to make it more lenient and accept the standard
source annotation, defaulting to 'code' type.
This does not matter for openerp-web, but makes sure
the server will not fail to load the new PO files
that contain openerp-web translations with standard
annotations.
The patch for making the server more lenient was
checked in trunk at revision 4002
rev-id odo@openerp.com-20120202143210-05p1w24t6u77cyv8
- The existing translation sync and export wizards for
regular addons have not been updated to consider
web addons, so for the time being we will have
to export regular addons terms first, and run the
web export script (gen_translations.sh) on the
addons directory afterwards. This could be improved
later.
As soon as this change is merged we will have to
perform a full update of addons translation
templates in order to include the web terms as well.
bzr revid: odo@openerp.com-20120202145603-ffo0il0qnfp3r6gt
2012-02-02 14:56:03 +00:00
|
|
|
def handle_text(text, lineno):
|
|
|
|
text = (text or "").strip()
|
|
|
|
if len(text) > 1: # Avoid mono-char tokens like ':' ',' etc.
|
|
|
|
result.append((lineno, None, text, [TRANSLATION_FLAG_COMMENT]))
|
|
|
|
|
2012-02-06 15:32:17 +00:00
|
|
|
# not using elementTree.iterparse because we need to skip sub-trees in case
|
|
|
|
# the ancestor element had a reason to be skipped
|
2011-08-17 11:28:28 +00:00
|
|
|
def iter_elements(current_element):
|
|
|
|
for el in current_element:
|
|
|
|
if "t-js" not in el.attrib and \
|
|
|
|
not ("t-jquery" in el.attrib and "t-operation" not in el.attrib) and \
|
2011-10-20 09:16:19 +00:00
|
|
|
not ("t-translation" in el.attrib and el.attrib["t-translation"].strip() == "off"):
|
[IMP] refactored translation system to merge web translations with addons translations
- Moved the web *.po files to /i18n to be consistent
with the addons convention. Using /po was considered
for a while because it played better with LP's auto-
detection of PO Templates, but that is not necessary
anymore, we now have full control on LP templates.
- In order to support addons that contain translations
for both the web addon and the regular addon part,
both kinds of translations are now merged in a single
addon/i18n/addon.pot file. Terms that are used by
the web part are now marked with a PO annotation:
#. openerp-web
so the web client can recognize them and only load
the relevant translations in the browser memory.
This is important because a complete PO file can
be rather large, e.g. account/i18n/de.po = 400KB.
- The web translation export scripts were updated to
behave properly for addons that have a non-web
part, and will merge the web translation in the
original POT file, annotating the web translations
as needed. These scripts are Unix-only and meant
to be used by OpenERP packagers when needed.
- The GetText spec says that PO auto-comments indicating
the source location have this form:
#: /path/to/file:lineno
However OpenERP's POT export system defaults to a modified
version of this format with an extra 'type' field:
#: type:/path/to/file:lineno
The babel extractors we use have the GetText format
hardcoded so a small patch is needed on the server
to make it more lenient and accept the standard
source annotation, defaulting to 'code' type.
This does not matter for openerp-web, but makes sure
the server will not fail to load the new PO files
that contain openerp-web translations with standard
annotations.
The patch for making the server more lenient was
checked in trunk at revision 4002
rev-id odo@openerp.com-20120202143210-05p1w24t6u77cyv8
- The existing translation sync and export wizards for
regular addons have not been updated to consider
web addons, so for the time being we will have
to export regular addons terms first, and run the
web export script (gen_translations.sh) on the
addons directory afterwards. This could be improved
later.
As soon as this change is merged we will have to
perform a full update of addons translation
templates in order to include the web terms as well.
bzr revid: odo@openerp.com-20120202145603-ffo0il0qnfp3r6gt
2012-02-02 14:56:03 +00:00
|
|
|
handle_text(el.text, el.sourceline)
|
2012-02-07 09:26:55 +00:00
|
|
|
for att in ('title', 'alt', 'label'):
|
|
|
|
if att in el.attrib:
|
|
|
|
handle_text(el.attrib[att], el.sourceline)
|
2011-08-17 11:28:28 +00:00
|
|
|
iter_elements(el)
|
[IMP] refactored translation system to merge web translations with addons translations
- Moved the web *.po files to /i18n to be consistent
with the addons convention. Using /po was considered
for a while because it played better with LP's auto-
detection of PO Templates, but that is not necessary
anymore, we now have full control on LP templates.
- In order to support addons that contain translations
for both the web addon and the regular addon part,
both kinds of translations are now merged in a single
addon/i18n/addon.pot file. Terms that are used by
the web part are now marked with a PO annotation:
#. openerp-web
so the web client can recognize them and only load
the relevant translations in the browser memory.
This is important because a complete PO file can
be rather large, e.g. account/i18n/de.po = 400KB.
- The web translation export scripts were updated to
behave properly for addons that have a non-web
part, and will merge the web translation in the
original POT file, annotating the web translations
as needed. These scripts are Unix-only and meant
to be used by OpenERP packagers when needed.
- The GetText spec says that PO auto-comments indicating
the source location have this form:
#: /path/to/file:lineno
However OpenERP's POT export system defaults to a modified
version of this format with an extra 'type' field:
#: type:/path/to/file:lineno
The babel extractors we use have the GetText format
hardcoded so a small patch is needed on the server
to make it more lenient and accept the standard
source annotation, defaulting to 'code' type.
This does not matter for openerp-web, but makes sure
the server will not fail to load the new PO files
that contain openerp-web translations with standard
annotations.
The patch for making the server more lenient was
checked in trunk at revision 4002
rev-id odo@openerp.com-20120202143210-05p1w24t6u77cyv8
- The existing translation sync and export wizards for
regular addons have not been updated to consider
web addons, so for the time being we will have
to export regular addons terms first, and run the
web export script (gen_translations.sh) on the
addons directory afterwards. This could be improved
later.
As soon as this change is merged we will have to
perform a full update of addons translation
templates in order to include the web terms as well.
bzr revid: odo@openerp.com-20120202145603-ffo0il0qnfp3r6gt
2012-02-02 14:56:03 +00:00
|
|
|
handle_text(el.tail, el.sourceline)
|
|
|
|
|
2011-08-17 11:28:28 +00:00
|
|
|
tree = elt.parse(fileobj)
|
|
|
|
iter_elements(tree.getroot())
|
|
|
|
|
2011-08-16 10:42:19 +00:00
|
|
|
return result
|
[IMP] refactored translation system to merge web translations with addons translations
- Moved the web *.po files to /i18n to be consistent
with the addons convention. Using /po was considered
for a while because it played better with LP's auto-
detection of PO Templates, but that is not necessary
anymore, we now have full control on LP templates.
- In order to support addons that contain translations
for both the web addon and the regular addon part,
both kinds of translations are now merged in a single
addon/i18n/addon.pot file. Terms that are used by
the web part are now marked with a PO annotation:
#. openerp-web
so the web client can recognize them and only load
the relevant translations in the browser memory.
This is important because a complete PO file can
be rather large, e.g. account/i18n/de.po = 400KB.
- The web translation export scripts were updated to
behave properly for addons that have a non-web
part, and will merge the web translation in the
original POT file, annotating the web translations
as needed. These scripts are Unix-only and meant
to be used by OpenERP packagers when needed.
- The GetText spec says that PO auto-comments indicating
the source location have this form:
#: /path/to/file:lineno
However OpenERP's POT export system defaults to a modified
version of this format with an extra 'type' field:
#: type:/path/to/file:lineno
The babel extractors we use have the GetText format
hardcoded so a small patch is needed on the server
to make it more lenient and accept the standard
source annotation, defaulting to 'code' type.
This does not matter for openerp-web, but makes sure
the server will not fail to load the new PO files
that contain openerp-web translations with standard
annotations.
The patch for making the server more lenient was
checked in trunk at revision 4002
rev-id odo@openerp.com-20120202143210-05p1w24t6u77cyv8
- The existing translation sync and export wizards for
regular addons have not been updated to consider
web addons, so for the time being we will have
to export regular addons terms first, and run the
web export script (gen_translations.sh) on the
addons directory afterwards. This could be improved
later.
As soon as this change is merged we will have to
perform a full update of addons translation
templates in order to include the web terms as well.
bzr revid: odo@openerp.com-20120202145603-ffo0il0qnfp3r6gt
2012-02-02 14:56:03 +00:00
|
|
|
|
|
|
|
def extract_javascript(fileobj, keywords, comment_tags, options):
|
|
|
|
"""Extract messages from Javascript source files. This extractor delegates
|
|
|
|
to babel's buit-in javascript extractor, but adds a special comment
|
|
|
|
used as a flag to identify web translations.
|
|
|
|
|
|
|
|
:param fileobj: the file-like object the messages should be extracted
|
|
|
|
from
|
|
|
|
:param keywords: a list of keywords (i.e. function names) that should
|
|
|
|
be recognized as translation functions
|
|
|
|
:param comment_tags: a list of translator tags to search for and
|
|
|
|
include in the results
|
|
|
|
:param options: a dictionary of additional options (optional)
|
|
|
|
:return: an iterator over ``(lineno, funcname, message, comments)``
|
|
|
|
tuples
|
|
|
|
:rtype: ``iterator``
|
|
|
|
"""
|
|
|
|
for (message_lineno, funcname, messages, comments) in \
|
|
|
|
extract.extract_javascript(fileobj, keywords, comment_tags, options):
|
|
|
|
comments.append(TRANSLATION_FLAG_COMMENT)
|
|
|
|
yield (message_lineno, funcname, messages, comments)
|