Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

Translation of js object in odoo owl component

Odoberať

Get notified when there's activity on this post

This question has been flagged
translationstranslationi18nowl
1 Odpoveď
302 Zobrazenia
Avatar
Konstantyn

Hello, I have a problem — I don’t know how to translate text inside an OWL component on a website.

For example, I have the following structure:

export const FORM_CONFIG = { [FORM_TYPES.SHORT]: { sections: [ { key: "test", title: "Doctor name" }, // ... another 100 fields ], }, };

How can I export this into my OWL Website components and make it translatable in Odoo?

The fields are generated dynamically, so I’m not sure how to include them in .po translation files.

0
Avatar
Zrušiť
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Best Answer

Hi,


To translate text within an OWL component on a website with dynamically generated fields, the best approach is to move the translatable data to the Odoo backend. Create a new Odoo model to store form configuration data, including a translatable field for the text. Populate this model with your existing data.


Modify your OWL component to fetch the form configuration data from Odoo using an RPC call. Update your QWeb template to iterate over the fetched data and render the form fields dynamically. Then, use Odoo's built-in translation mechanism to translate the text in the database records. This leverages Odoo's translation system, supports dynamic content, and improves maintainability.


Sample code:

Python


from odoo import models, fields


class WebsiteFormConfig(models.Model):

    _name = 'website.form.config'

    _description = 'Website Form Configuration'


    form_type = fields.Selection([

        ('short', 'Short Form'),

        # Add other form types

    ], string='Form Type')

    section_key = fields.Char(string='Section Key')

    section_title = fields.Char(string='Section Title', translate=True)


JS


/** @odoo-module **/


import { Component, onWillStart } from "@odoo/owl";

import { useService } from "@web/core/utils/hooks";


export class MyFormComponent extends Component {

    setup() {

        this.orm = useService("orm");

        this.formConfig = [];


        onWillStart(async () => {

            this.formConfig = await this.fetchFormConfig();

        });

    }


    async fetchFormConfig() {

        return await this.orm.searchRead(

            "website.form.config",

            [['form_type', '=', 'short']], // Adjust domain as needed

            ['section_key', 'section_title'] // Adjust fields as needed

        );

    }

}


MyFormComponent.template = "your_module.my_form_template"; // Replace with your template



QWeb template


<t t-name="your_module.my_form_template">

    <div class="my-form">

        <t t-foreach="formConfig" t-as="section">

            <div t-attf-class="form-section #{section.section_key}">

                <label t-esc="section.section_title"/>

                <!-- Add your input field here -->

            </div>

        </t>

    </div>

</t>


Hope it helps

0
Avatar
Zrušiť
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Registrácia
Related Posts Replies Zobrazenia Aktivita
How to correctly handle grammatical gender inflection in Ukrainian translation?
translation owl
Avatar
0
nov 25
142
Thank you message to translate
translations translation
Avatar
Avatar
1
mar 21
4271
Website_sale (user cart) translation problem (reload i18n translation) Solved
translation i18n website_sale
Avatar
1
jún 24
6165
how can one translate the unsubscribe page? Solved
translations translation unsubscribe
Avatar
Avatar
1
júl 23
2977
Translate module - v16
translations translation odoo16features
Avatar
0
mar 23
3038
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now