Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Coopdevs OCB mirror
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Coopdevs
Odoo
Coopdevs OCB mirror
Commits
97aa297b
Commit
97aa297b
authored
11 years ago
by
Martin Trigaux
Browse files
Options
Downloads
Patches
Plain Diff
[IMP] l10n_multilang: add translation_folder field
bzr revid: mat@openerp.com-20130813094730-8wbjph5qsfp0z84o
parent
1bdd49c2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
addons/l10n_multilang/l10n_multilang.py
+46
-2
46 additions, 2 deletions
addons/l10n_multilang/l10n_multilang.py
with
46 additions
and
2 deletions
addons/l10n_multilang/l10n_multilang.py
+
46
−
2
View file @
97aa297b
...
...
@@ -19,8 +19,9 @@
#
##############################################################################
from
openerp
import
tools
from
openerp
import
SUPERUSER_ID
from
openerp.osv
import
fields
,
osv
import
os
from
openerp.tools.translate
import
_
import
logging
_logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -152,4 +153,47 @@ class wizard_multi_charts_accounts(osv.osv_memory):
wizard_multi_charts_accounts
()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
class
module
(
osv
.
osv
):
_inherit
=
"
ir.module.module
"
_columns
=
{
'
translation_folder
'
:
fields
.
char
(
"
Additional Translation Folder
"
,
size
=
256
,
help
=
"
Relative path name of a folder containing the translations for this module in addtion to i18n/.
"
)
}
def
get_values_from_terp
(
self
,
terp
):
info
=
super
(
module
,
self
).
get_values_from_terp
(
terp
)
info
.
update
({
'
translation_folder
'
:
terp
.
get
(
'
translation_folder
'
,
False
)})
return
info
class
ir_translation
(
osv
.
osv
):
_inherit
=
"
ir.translation
"
def
load
(
self
,
cr
,
modules
,
langs
,
context
=
None
):
res
=
super
(
ir_translation
,
self
).
load
(
cr
,
modules
,
context
=
context
)
context
=
dict
(
context
or
{})
# local copy
module_ids
=
self
.
pool
.
get
(
'
ir.module.module
'
).
search
(
cr
,
SUPERUSER_ID
,
[(
'
name
'
,
'
in
'
,
modules
)],
context
=
context
)
for
module
in
self
.
browse
(
cr
,
SUPERUSER_ID
,
module_ids
,
context
=
context
):
for
lang
in
langs
:
lang_code
=
tools
.
get_iso_codes
(
lang
)
base_lang_code
=
None
if
'
_
'
in
lang_code
:
base_lang_code
=
lang_code
.
split
(
'
_
'
)[
0
]
# Step 3: if additional translation folder is specified, load it as well
if
module
.
translation_folder
:
module_name
=
module
.
name
base_trans_file
=
openerp
.
modules
.
get_module_resource
(
module_name
,
module
.
translation_folder
,
base_lang_code
+
'
.po
'
)
if
base_trans_file
:
_logger
.
info
(
'
module %s: loading base translation file %s for language %s
'
,
module_name
,
base_lang_code
,
lang
)
tools
.
trans_load
(
cr
,
base_trans_file
,
lang
,
verbose
=
False
,
module_name
=
module_name
,
context
=
context
)
context
[
'
overwrite
'
]
=
True
# make sure the requested translation will override the base terms later
trans_file
=
openerp
.
modules
.
get_module_resource
(
module_name
,
module
.
translation_folder
,
lang_code
+
'
.po
'
)
if
trans_file
:
_logger
.
info
(
'
module %s: loading translation file (%s) for language %s
'
,
module_name
,
lang_code
,
lang
)
tools
.
trans_load
(
cr
,
trans_file
,
lang
,
verbose
=
False
,
module_name
=
module_name
,
context
=
context
)
elif
lang_code
!=
'
en_US
'
:
_logger
.
warning
(
'
module %s: no translation for language %s
'
,
module_name
,
lang_code
)
return
res
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment