Skip to content

Commit

Permalink
TA#66815 [MIG][16.0] lang_fr_activated (#141)
Browse files Browse the repository at this point in the history
Co-authored-by: Majda EL MARIOULI <[email protected]>
  • Loading branch information
lanto-razafindrabe and majouda committed Sep 3, 2024
1 parent 76e8bea commit c977709
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 0 deletions.
25 changes: 25 additions & 0 deletions lang_fr_activated/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
====================
Lang fr_FR Activated
====================
This module loads the language fr_FR on installation.

Context
-------
When installing Odoo, only en_US is loaded by default.

In Canada, it is better to use fr_FR instead of fr_CA, because the latter one is more or less maintained.

Requirement
-----------
Some modules (such as canada_mis_report) require to load fr_FR translations directly in python
instead of a .po file.

The language must therefore be loaded automatically before installing these modules.

Contributors
------------
* Numigi (tm) and all its contributors (https://bit.ly/numigiens)

More information
----------------
* Meet us at https://bit.ly/numigi-com
4 changes: 4 additions & 0 deletions lang_fr_activated/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2024-today Numigi and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from .init_hook import post_init_hook
17 changes: 17 additions & 0 deletions lang_fr_activated/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2024-today Numigi and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

{
"name": "Lang fr_FR activated",
"version": "16.0.1.0.0",
"author": "Numigi",
"maintainer": "Numigi",
"license": "LGPL-3",
"category": "Other",
"summary": "Automatically activate the fr_FR language",
"depends": [
"base",
],
"post_init_hook": "post_init_hook",
"installable": True,
}
Binary file added lang_fr_activated/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions lang_fr_activated/init_hook.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2024-today Numigi and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from odoo import SUPERUSER_ID
from odoo.api import Environment


def post_init_hook(cr, _):
env = Environment(cr, SUPERUSER_ID, {})
activate_fr_lang_if_inactive(env)


def activate_fr_lang_if_inactive(env):
lang = env.ref("base.lang_fr")
if not lang.active:
env["res.lang"]._activate_lang("fr_FR")

0 comments on commit c977709

Please sign in to comment.