Browse Source

[ADD] Initial Commit

pull/30/merge
SHEREEF PT 8 years ago
parent
commit
cf2f6a6647
  1. 24
      translation_helper/__init__.py
  2. 45
      translation_helper/__manifest__.py
  3. 159
      translation_helper/data/lang_data.xml
  4. 24
      translation_helper/models/__init__.py
  5. 61
      translation_helper/models/translation_helper.py
  6. 2
      translation_helper/security/ir.model.access.csv
  7. BIN
      translation_helper/static/description/banner.jpg
  8. BIN
      translation_helper/static/description/cybro_logo.png
  9. BIN
      translation_helper/static/description/icon.png
  10. 108
      translation_helper/static/description/index.html
  11. BIN
      translation_helper/static/description/translate_button.png
  12. 25
      translation_helper/views/translation.xml

24
translation_helper/__init__.py

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2017-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: LINTO C T(<https://www.cybrosys.com>)
# you can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# It is forbidden to publish, distribute, sublicense, or sell copies
# of the Software or modified copies of the Software.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# GENERAL PUBLIC LICENSE (LGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import models

45
translation_helper/__manifest__.py

@ -0,0 +1,45 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2017-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: Linto C T(<https://www.cybrosys.com>)
# you can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# It is forbidden to publish, distribute, sublicense, or sell copies
# of the Software or modified copies of the Software.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# GENERAL PUBLIC LICENSE (LGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'name': 'Translation Helper',
'version': '10.0.1.0.0',
'category': 'Extra Tools',
'summary': """Button To Translate New Words Using 'googletrans'.""",
'description': """This module will help you to translate new words.""",
'author': 'Cybrosys Techno Solutions',
'website': "https://www.cybrosys.com",
'company': 'Cybrosys Techno Solutions',
'maintainer': 'Cybrosys Techno Solutions',
'depends': ['base'],
'external_dependencies': {'python': ['googletrans']},
'data': [
'data/lang_data.xml',
'views/translation.xml',
'security/ir.model.access.csv',
],
'images': ['static/description/banner.jpg'],
'license': 'LGPL-3',
'installable': True,
'auto_install': False,
'application': False,
}

159
translation_helper/data/lang_data.xml

@ -0,0 +1,159 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo noupdate="1">
<record model="languages.list" id="l1">
<field name="name">Greek / Ελληνικά</field>
<field name="code">el</field>
</record>
<record model="languages.list" id="l2">
<field name="name">English</field>
<field name="code">en</field>
</record>
<record model="languages.list" id="l3">
<field name="name">Catalan / Català</field>
<field name="code">ca</field>
</record>
<record model="languages.list" id="l4">
<field name="name">Italian / Italiano</field>
<field name="code">it</field>
</record>
<record model="languages.list" id="l5">
<field name="name">Swedish / svenska</field>
<field name="code">sv</field>
</record>
<record model="languages.list" id="l6">
<field name="name">Czech / Čeština</field>
<field name="code">cs</field>
</record>
<record model="languages.list" id="l7">
<field name="name">Arabic / الْعَرَبيّة</field>
<field name="code">ar</field>
</record>
<record model="languages.list" id="l8">
<field name="name">Estonian / Eesti keel</field>
<field name="code">et</field>
</record>
<record model="languages.list" id="l9">
<field name="name">Indonesian / Bahasa Indonesia</field>
<field name="code">id</field>
</record>
<record model="languages.list" id="l10">
<field name="name">Spanish / Español</field>
<field name="code">es</field>
</record>
<record model="languages.list" id="l11">
<field name="name">Russian / русский язык</field>
<field name="code">es</field>
</record>
<record model="languages.list" id="l12">
<field name="name">Dutch / Nederlands</field>
<field name="code">nl</field>
</record>
<record model="languages.list" id="l13">
<field name="name">Portuguese / Português</field>
<field name="code">pt</field>
</record>
<record model="languages.list" id="l13">
<field name="name">Turkish / Türkçe</field>
<field name="code">tr</field>
</record>
<record model="languages.list" id="l14">
<field name="name">Latvian / latviešu valoda</field>
<field name="code">lv</field>
</record>
<record model="languages.list" id="l15">
<field name="name">Lithuanian / Lietuvių kalba</field>
<field name="code">lt</field>
</record>
<record model="languages.list" id="l16">
<field name="name">Thai / ภาษาไทย</field>
<field name="code">th</field>
</record>
<record model="languages.list" id="l17">
<field name="name">Vietnamese / Tiếng Việt</field>
<field name="code">vi</field>
</record>
<record model="languages.list" id="l18">
<field name="name">Romanian / română</field>
<field name="code">ro</field>
</record>
<record model="languages.list" id="l19">
<field name="name">Polish / Język polski</field>
<field name="code">pl</field>
</record>
<record model="languages.list" id="l20">
<field name="name">French / Français</field>
<field name="code">fr</field>
</record>
<record model="languages.list" id="l21">
<field name="name">Bulgarian / български език</field>
<field name="code">bg</field>
</record>
<record model="languages.list" id="l22">
<field name="name">Ukrainian / українська</field>
<field name="code">uk</field>
</record>
<record model="languages.list" id="l23">
<field name="name">Croatian / hrvatski jezik</field>
<field name="code">hr</field>
</record>
<record model="languages.list" id="l24">
<field name="name">Slovenian / slovenščina</field>
<field name="code">sl</field>
</record>
<record model="languages.list" id="l25">
<field name="name">Danish / Dansk</field>
<field name="code">da</field>
</record>
<record model="languages.list" id="l26">
<field name="name">Persian / فارس</field>
<field name="code">fa</field>
</record>
<record model="languages.list" id="l27">
<field name="name">Hindi / हिंदी</field>
<field name="code">hi</field>
</record>
<record model="languages.list" id="l28">
<field name="name">Finnish / Suomi</field>
<field name="code">fi</field>
</record>
<record model="languages.list" id="l29">
<field name="name">Hungarian / Magyar</field>
<field name="code">hu</field>
</record>
<record model="languages.list" id="l30">
<field name="name">Japanese / 日本語</field>
<field name="code">ja</field>
</record>
<record model="languages.list" id="l31">
<field name="name">Norwegian Bokmål / Norsk bokmål</field>
<field name="code">no</field>
</record>
<record model="languages.list" id="l32">
<field name="name">Korean (KP) / 한국어 (KP)</field>
<field name="code">ko</field>
</record>
<record model="languages.list" id="l33">
<field name="name">Korean (KP) / 한국어 (KP)Korean (KR) / 한국어 (KR)</field>
<field name="code">ko</field>
</record>
<record model="languages.list" id="l34">
<field name="name">Slovak / Slovenský jazyk</field>
<field name="code">sk</field>
</record>
<record model="languages.list" id="l35">
<field name="name">Slovak / Slovenský jazyk</field>
<field name="code">sk</field>
</record>
<record model="languages.list" id="l36">
<field name="name">German / Deutsch</field>
<field name="code">de</field>
</record>
<record model="languages.list" id="l37">
<field name="name">German (CH) / Deutsch (CH)</field>
<field name="code">de</field>
</record>
<record model="languages.list" id="l37">
<field name="name">German (CH) / Deutsch (CH)</field>
<field name="code">de</field>
</record>
</odoo>

24
translation_helper/models/__init__.py

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2017-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: LINTO C T(<https://www.cybrosys.com>)
# you can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# It is forbidden to publish, distribute, sublicense, or sell copies
# of the Software or modified copies of the Software.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# GENERAL PUBLIC LICENSE (LGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import translation_helper

61
translation_helper/models/translation_helper.py

@ -0,0 +1,61 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2017-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: LINTO C T(<https://www.cybrosys.com>)
# you can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# It is forbidden to publish, distribute, sublicense, or sell copies
# of the Software or modified copies of the Software.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# GENERAL PUBLIC LICENSE (LGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import time
try:
from googletrans import Translator
translator = Translator()
except ImportError:
print "Unable to import "
from odoo import models, fields, _
from odoo.exceptions import UserError
class LanguageList(models.Model):
_name = 'languages.list'
name = fields.Char(string="Name")
code = fields.Char(string="Code")
class TranslationHelper(models.Model):
_inherit = 'ir.translation'
def translate_term(self):
if self.lang:
lang = dict(self.fields_get(allfields=['lang'])['lang']['selection'])[self.lang]
rec = self.env['languages.list'].search([('name', '=', lang)], limit=1)
if rec:
code = rec.code
if self.source and code:
try:
val = translator.translate(self.source, dest=code)
time.sleep(1)
self.value = val.text
except:
raise UserError(_("No Translation Found. Please Check Your Internet Connection."))
else:
raise UserError(_("There is nothing to translate !"))
else:
raise UserError(_("Select a language!"))

2
translation_helper/security/ir.model.access.csv

@ -0,0 +1,2 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
administration_settings,access_administration,translation_helper.model_languages_list,base.group_system,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 administration_settings access_administration translation_helper.model_languages_list base.group_system 1 1 1 1

BIN
translation_helper/static/description/banner.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 KiB

BIN
translation_helper/static/description/cybro_logo.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

BIN
translation_helper/static/description/icon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

108
translation_helper/static/description/index.html

@ -0,0 +1,108 @@
<section class="oe_container">
<div class="oe_row oe_spaced">
<h2 class="oe_slogan">Translation Helper</h2>
<h3 class="oe_slogan">..Single Click To Translate New Words..</h3>
<h4 class="oe_slogan"><a href="https://www.cybrosys.com">Cybrosys Technologies</a> </h4>
</div>
<div class="oe_row oe_spaced" style="padding-left:65px;">
<h4>Features:</h4>
<div>
<span style="color:green;"> &#9745; </span> Translate words to other languages using 'googletrans'.<br/>
</div>
</div>
</section>
<section class="oe_container oe_dark">
<div class="oe_row oe_spaced">
<div class="oe_picture">
<h3 class="oe_slogan">Overview</h3>
<p class="oe_mt32">
Creating translations for new words has became simple with this module. It can be done in a single
button click.
</p>
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced">
<div>
<h3 style="color:brown;"><b><i><u>Note</u>:</i></b></h3>
<p>For the perfect working, we have to install an external dependency, <b><i>'googlerans'</i></b>
using <b><i>'pip install googletrans'</i></b>.</p>
</div>
</div>
</section>
<section class="oe_container oe_dark">
<div class="oe_row oe_spaced">
<div>
<p class="text-justify"> With the help of this module, finding translation for new words has become more easier in odoo.
Instead of finding the translation manually, we can automate that process. We just need to provide the
source which we need to translate and the language to which we need to translate the source. A new button,
'Translate' is added for this purpose. </p>
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced">
<h3 class="oe_slogan">Translate button</h3>
<div class="oe_span12" style="text-align: center;">
<div class="oe_demo oe_picture oe_screenshot">
<img style="border:10px solid white;width:87% !important;" src="translate_button.png">
</div>
</div>
<br><br><br>
<div>
<div>
<p class="text-justify">
For creating a new translation, first enable the debug mode and go to
Settings - > Translation - > Application Terms -> Translated Terms. We can create new
translations from here. After entering the source value, language and the other required details,
click on the 'Translate' button. After clicking the button, it will automatically find the translation
for the source and fill the value in the translated value column.
<p>
<p>
We can translate to 36 different languages with the help of this module.
</p>
</div>
</div>
</div>
</section>
<section class="oe_container oe_dark">
<div class="oe_row oe_spaced">
<h3 style="color:brown;"><b><i><u>Note</u>:</i></b></h3>
<br />
<p> Please make sure that there is proper internet connection. Without proper internet connection, not all the
facilities of this module will work.
</p>
</div>
</section>
<section class="oe_container">
<h2 class="oe_slogan" style="margin-top:20px;" >Need Any Help?</h2>
<div class="oe_slogan" style="margin-top:10px !important;">
<div>
<a class="btn btn-primary btn-lg mt8"
style="color: #FFFFFF !important;border-radius: 0;" href="https://www.cybrosys.com"><i
class="fa fa-envelope"></i> Email </a> <a
class="btn btn-primary btn-lg mt8" style="color: #FFFFFF !important;border-radius: 0;"
href="https://www.cybrosys.com/contact/"><i
class="fa fa-phone"></i> Contact Us </a> <a
class="btn btn-primary btn-lg mt8" style="color: #FFFFFF !important;border-radius: 0;"
href="https://www.cybrosys.com/odoo-customization-and-installation/"><i
class="fa fa-check-square"></i> Request Customization </a>
</div>
<br>
<img src="cybro_logo.png" style="width: 190px; margin-bottom: 20px;" class="center-block">
<div>
<a href="https://twitter.com/cybrosys" target="_blank"><i class="fa fa-2x fa-twitter" style="color:white;background: #00a0d1;width:35px;"></i></a></td>
<a href="https://www.linkedin.com/company/cybrosys-technologies-pvt-ltd" target="_blank"><i class="fa fa-2x fa-linkedin" style="color:white;background: #31a3d6;width:35px;padding-left: 3px;"></i></a></td>
<a href="https://www.facebook.com/cybrosystechnologies" target="_blank"><i class="fa fa-2x fa-facebook" style="color:white;background: #3b5998;width:35px;padding-left: 8px;"></i></a></td>
<a href="https://plus.google.com/106641282743045431892/about" target="_blank"><i class="fa fa-2x fa-google-plus" style="color:white;background: #c53c2c;width:35px;padding-left: 3px;"></i></a></td>
<a href="https://in.pinterest.com/cybrosys" target="_blank"><i class="fa fa-2x fa-pinterest" style="color:white;background: #ac0f18;width:35px;padding-left: 3px;"></i></a></td>
</div>
</div>
</section>

BIN
translation_helper/static/description/translate_button.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

25
translation_helper/views/translation.xml

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<data>
<record model="ir.ui.view" id="translator_helper_tree">
<field name="name">translator.helper.tree</field>
<field name="model">ir.translation</field>
<field name="inherit_id" ref="base.view_translation_tree" />
<field name="arch" type="xml">
<xpath expr="//field[@name='source']" position="after">
<button name="translate_term" class="oe_highlight" string="Translate" id="translate_source" type="object" />
</xpath>
</field>
</record>
<record model="ir.ui.view" id="translator_helper_dialogue_tree">
<field name="name">translator.helper_dialogue.tree</field>
<field name="model">ir.translation</field>
<field name="inherit_id" ref="base.view_translation_dialog_tree" />
<field name="arch" type="xml">
<xpath expr="//field[@name='source']" position="after">
<button name="translate_term" class="oe_highlight" string="Translate" id="translate_source" type="object" />
</xpath>
</field>
</record>
</data>
</odoo>
Loading…
Cancel
Save