Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by moylop260
- Loading branch information
Showing
18 changed files
with
811 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
=========================== | ||
Export translatable strings | ||
=========================== | ||
|
||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png | ||
:target: https://odoo-community.org/page/development-status | ||
:alt: Beta | ||
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Frunbot--addons-lightgray.png?logo=github | ||
:target: https://github.com/OCA/runbot-addons/tree/11.0/runbot_push_pot | ||
:alt: OCA/runbot-addons | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/runbot-addons-11-0/runbot-addons-11-0-runbot_push_pot | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png | ||
:target: https://runbot.odoo-community.org/runbot/146/11.0 | ||
:alt: Try me on Runbot | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module exports translations for your builds and pushes them back to your repository. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Configuration | ||
============= | ||
|
||
To configure this module, you need to: | ||
|
||
#. give the user running your runbot write access to the repositories in question | ||
#. go to one of your stable branches and check the box ``Push Pot`` | ||
|
||
Usage | ||
===== | ||
|
||
This module presupposes a directory structure like:: | ||
|
||
addon_name/i18n/addon_name.pot | ||
|
||
in the root of your repository. | ||
|
||
So if you don't have that, it won't work for you. | ||
|
||
Known issues / Roadmap | ||
====================== | ||
|
||
* investigate if we can do the commit via the API using the exsiting git{hub,lab} token | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/runbot-addons/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us smashing it by providing a detailed and welcomed | ||
`feedback <https://github.com/OCA/runbot-addons/issues/new?body=module:%20runbot_push_pot%0Aversion:%2011.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
~~~~~~~ | ||
|
||
* Therp BV | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Holger Brunn <hbrunn@therp.nl> | ||
|
||
Other credits | ||
~~~~~~~~~~~~~ | ||
|
||
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_. | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
||
This module is maintained by the OCA. | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
OCA, or the Odoo Community Association, is a nonprofit organization whose | ||
mission is to support the collaborative development of Odoo features and | ||
promote its widespread use. | ||
|
||
This module is part of the `OCA/runbot-addons <https://github.com/OCA/runbot-addons/tree/11.0/runbot_push_pot>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Copyright 2019 Therp BV <https://therp.nl> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Copyright 2019 Therp BV <https://therp.nl> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
{ | ||
"name": "Export translatable strings", | ||
"version": "11.0.1.0.0", | ||
"author": "Therp BV,Odoo Community Association (OCA)", | ||
"license": "AGPL-3", | ||
"category": "Runbot", | ||
"summary": "Export & push .pot files to your repo", | ||
"depends": [ | ||
'runbot', | ||
], | ||
"data": [ | ||
"views/runbot_branch.xml", | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Copyright 2019 Therp BV <https://therp.nl> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
from . import runbot_build | ||
from . import runbot_branch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Copyright 2019 Therp BV <https://therp.nl> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
from odoo import fields, models | ||
|
||
|
||
class RunbotBranch(models.Model): | ||
_inherit = 'runbot.branch' | ||
|
||
push_pot = fields.Boolean( | ||
default=False, help='Enable this on your stable branch to have runbot ' | ||
'push new translatable strings to your repo. Note this will overwrite ' | ||
'your existing pot file', | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# Copyright 2019 Therp BV <https://therp.nl> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
import multiprocessing | ||
import subprocess | ||
import tarfile | ||
import tempfile | ||
from odoo import models | ||
from odoo.addons.runbot.common import lock | ||
|
||
|
||
class RunbotBuild(models.Model): | ||
_inherit = 'runbot.build' | ||
|
||
def _job_29_export_translations(self, build, lock_path, log_path): | ||
if not build.branch_id.push_pot or build.build_type == 'rebuild': | ||
return -2 | ||
command, modules = build._cmd() | ||
process = multiprocessing.Process( | ||
target=self._export_translations.__func__, | ||
args=( | ||
None, | ||
command, modules, build.repo_id.path, build.repo_id.name, | ||
build.branch_id.branch_name, '%s-all' % build.dest, lock_path, | ||
log_path, self.env['ir.config_parameter'].get_param( | ||
'runbot_push_pot.commit_message', | ||
'[UPD] updated translations from runbot', | ||
), | ||
), | ||
name='translation export for %s' % build, | ||
) | ||
process.start() | ||
return process.pid | ||
|
||
def _export_translations( | ||
self, command, modules, repo_path, repo_url, branch_name, db_name, | ||
lock_path, log_path, commit_message, | ||
): | ||
"""Do the actual translation export. Note you can't override this | ||
because we don't use it as a class member""" | ||
lock(lock_path) | ||
with open(log_path, 'w') as log_file, tempfile.NamedTemporaryFile( | ||
suffix='.tgz', delete=False, | ||
) as translation_file: | ||
command.extend([ | ||
'-d', db_name, | ||
'--i18n-export', translation_file.name, | ||
'--modules', modules, | ||
'--stop-after-init', | ||
]) | ||
subprocess.check_call( | ||
command, stdout=log_file, stderr=log_file, | ||
) | ||
translations = tarfile.open(translation_file.name) | ||
with tempfile.TemporaryDirectory() as checkout: | ||
subprocess.run( | ||
['git', 'clone', repo_path, checkout], | ||
stdout=log_file, stderr=log_file, | ||
) | ||
|
||
def git(*cmd, **kwargs): | ||
cmd = ('git', '-C', checkout) + cmd | ||
return subprocess.run( | ||
cmd, stdout=log_file, stderr=log_file, **kwargs | ||
) | ||
|
||
git('checkout', branch_name) | ||
translations.extractall(checkout) | ||
git('add', '.') | ||
diff_lines = [ | ||
line for line in | ||
subprocess.run( | ||
['git', '-C', checkout, 'diff', 'HEAD', '-U0'], | ||
capture_output=True | ||
).stdout.decode('utf8').split('\n') | ||
if | ||
# we want only lines from the diff where we actually have | ||
# changes, and we want to ignore the date fields because | ||
# they change for every export | ||
(line.startswith('+') or line.startswith('-')) and not | ||
(line.startswith('+++') or line.startswith('---')) and | ||
'POT-Creation-Date' not in line and | ||
'PO-Revision-Date' not in line | ||
] | ||
if diff_lines: | ||
git('commit', '-m', commit_message) | ||
git('push', repo_url, branch_name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
To configure this module, you need to: | ||
|
||
#. give the user running your runbot write access to the repositories in question | ||
#. go to one of your stable branches and check the box ``Push Pot`` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* Holger Brunn <hbrunn@therp.nl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This module exports translations for your builds and pushes them back to your repository. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* investigate if we can do the commit via the API using the exsiting git{hub,lab} token |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
This module presupposes a directory structure like:: | ||
|
||
addon_name/i18n/addon_name.pot | ||
|
||
in the root of your repository. | ||
|
||
So if you don't have that, it won't work for you. |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.