Skip to content

Commit 84c8850

Browse files
committed
[WIP][ADD] translation module
1 parent b42b0f8 commit 84c8850

File tree

13 files changed

+161
-0
lines changed

13 files changed

+161
-0
lines changed

addons/t9n/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models

addons/t9n/__manifest__.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "Translations",
3+
"version": "1.0",
4+
"category": "TODO: find the appropriate category",
5+
"description": "TODO: write a description of the module",
6+
"depends": ["base", "web"],
7+
"data": [
8+
"views/t9n_templates.xml"
9+
],
10+
"application": True,
11+
"assets": {
12+
"web.assets_backend": [
13+
"t9n/static/src/**/*",
14+
],
15+
},
16+
"license": "LGPL-3",
17+
}

addons/t9n/models/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from . import language
2+
from . import message
3+
from . import project
4+
from . import resource
5+
from . import translation

addons/t9n/models/language.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from odoo import fields, models
2+
3+
4+
class Language(models.Model):
5+
_name = "t9n.language"
6+
_description = "Language"

addons/t9n/models/message.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from odoo import fields, models
2+
3+
4+
class Message(models.Model):
5+
""" Models a localizable message, i.e. any textual content to be translated.
6+
Messages are retrieved from a Resource.
7+
A Message localized to a specific Language becomes a Translation.
8+
"""
9+
_name = "t9n.message"
10+
_description = "Localizable message"
11+
12+
body = fields.Text(
13+
help="The actual, textual content to be translated.",
14+
)
15+
resource_id = fields.Many2one(
16+
comodel_name="t9n.resource",
17+
help="The resource (typically a file) from which the entry is coming from."
18+
)
19+
translation_ids = fields.One2many(
20+
comodel_name="t9n.translation",
21+
inverse_name="source_id",
22+
string="Translations",
23+
)

addons/t9n/models/project.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from odoo import fields, models
2+
3+
4+
class Project(models.Model):
5+
""" A project is a collection of Resources to be localized into a given set
6+
of Languages.
7+
"""
8+
_name = "t9n.project"
9+
_description = "Translation project"
10+
11+
src_lang_id = fields.Many2one(
12+
comodel_name="t9n.language",
13+
string="Source Language",
14+
help="The original language of the messages you want to translate."
15+
)
16+
resource_ids = fields.One2many(
17+
comodel_name="t9n.resource",
18+
inverse_name="project_id",
19+
string="Resources",
20+
)
21+
target_lang_ids = fields.Many2many(
22+
comodel_name="t9n.language",
23+
string="Languages",
24+
help="The list of languages into which the project can be translated.",
25+
)

addons/t9n/models/resource.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from odoo import fields, models
2+
3+
4+
class Resource(models.Model):
5+
_name = "t9n.resource"
6+
_description = "Resource file"
7+
8+
message_ids = fields.One2many(
9+
comodel_name="t9n.message",
10+
inverse_name="resource_id",
11+
string="Entries to translate",
12+
)
13+
project_id = fields.Many2one(
14+
comodel_name="t9n.project",
15+
)

addons/t9n/models/translation.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from odoo import fields, models
2+
3+
4+
class Translation(models.Model):
5+
_name = "t9n.translation"
6+
_description = "Message translated into a language"
7+
8+
body = fields.Text(
9+
help="The actual content of the translation.",
10+
)
11+
source_id = fields.Many2one(
12+
comodel_name="t9n.message",
13+
string="Source message",
14+
help="The original text, the source of the translation.",
15+
)
16+
lang_id = fields.Many2one(
17+
comodel_name="t9n.language",
18+
string="Language",
19+
help="The language to which the translation translates the original message.",
20+
)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink

addons/t9n/static/src/core/app.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Component } from "@odoo/owl";
2+
3+
/**
4+
* The "root", the "homepage" of the translation application.
5+
*/
6+
export class App extends Component {
7+
static components = {};
8+
static props = {};
9+
static template = "t9n.App";
10+
}

addons/t9n/static/src/core/app.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0"?>
2+
<templates xml:space="preserve">
3+
4+
<t t-name="t9n.App">
5+
Hello World!
6+
</t>
7+
8+
</templates>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { Component, xml } from "@odoo/owl";
2+
3+
import { App } from "@t9n/core/app";
4+
5+
import { registry } from "@web/core/registry";
6+
import { standardActionServiceProps } from "@web/webclient/actions/action_service";
7+
8+
/**
9+
* Wraps the application root, allowing us to open the application as a result
10+
* of a call to the "t9n.open_app" client action.
11+
*/
12+
export class OpenApp extends Component {
13+
static components = { App };
14+
static props = { ...standardActionServiceProps };
15+
static template = xml`<App/>`;
16+
}
17+
18+
registry.category("actions").add("t9n.open_app", OpenApp);

addons/t9n/views/t9n_templates.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0"?>
2+
<odoo>
3+
<data>
4+
<record id="t9n.open_app" model="ir.actions.client">
5+
<field name="name">Translate</field>
6+
<field name="tag">t9n.open_app</field>
7+
<field name="target">main</field>
8+
</record>
9+
10+
<menuitem id="t9n.menu_root" name="Translations" action="t9n.open_app"/>
11+
</data>
12+
</odoo>

0 commit comments

Comments
 (0)