Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
ICU Format
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package Registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
XCG
Odoo modules
ICU Format
Commits
4c6bf2470d3e
Commit
4c6bf2470d3e
authored
5 years ago
by
Vincent Hatakeyama
Browse files
Options
Downloads
Patches
Plain Diff
make icuformat a method available to all models
parent
3d2a2e974645
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
__manifest__.py
+1
-1
1 addition, 1 deletion
__manifest__.py
icuformat.py
+13
-0
13 additions, 0 deletions
icuformat.py
with
14 additions
and
1 deletion
__manifest__.py
+
1
−
1
View file @
4c6bf247
...
...
@@ -20,7 +20,7 @@
{
'
name
'
:
'
ICU Format
'
,
'
summary
'
:
'
Format message using ICU
'
,
'
version
'
:
'
11.0.
0.1
'
,
'
version
'
:
'
11.0.
1.0
'
,
'
category
'
:
'
Technical
'
,
'
author
'
:
'
XCG Consulting
'
,
'
website
'
:
'
http://odoo.consulting/
'
,
...
...
This diff is collapsed.
Click to expand it.
icuformat.py
+
13
−
0
View file @
4c6bf247
...
...
@@ -18,6 +18,8 @@
##############################################################################
from
typing
import
Dict
,
Union
from
odoo.models
import
BaseModel
from
icu
import
Formattable
,
Locale
,
MessageFormat
...
...
@@ -31,3 +33,14 @@
lang
=
'
en
'
locale
=
Locale
(
lang
)
return
MessageFormat
(
msg
,
locale
).
format
(
key_list
,
value_list
)
def
_icuformat
(
self
,
msg
:
str
,
args
:
Dict
[
str
,
Union
[
int
,
str
]])
->
str
:
return
icuformat
(
self
.
env
.
context
.
get
(
'
lang
'
)
or
self
.
env
.
user
.
lang
,
msg
,
args
,
)
setattr
(
BaseModel
,
'
icuformat
'
,
_icuformat
)
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