Announcement

Collapse
No announcement yet.

Custom scope/file for translate

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Custom scope/file for translate

    Hello!

    I have a lot of custom pages with information with hard-coded language but now i need to add translations.
    Because i have a custom pages those pages do not belong to any scope so i have tried this step:

    1. I created a custom json file in custom/Espo/Custom/Resources/i18n/pl_PL/CustomStat.json with body you can see on screenshot
    2. And in JS i tried: this.getLanguage().translate('someField', 'fields', 'CustomStat') but this return me 'someField' but in JSON it 'someFieldValue' so i want to return 'someFieldValue'

    How i can do that? Thanks for any replies.
    Attached Files

  • #2
    Did you try with something different like:

    Code:
    this.language.translate(someField, 'fields', CustomStat)
    or
    Code:
    this.getLanguage().translate(item, 'fields', this.scope)
    Last edited by Kharg; 03-16-2022, 03:43 PM.

    Comment


    • cossplay
      cossplay commented
      Editing a comment
      Thanks for reply!

      But thats not working .
      this.language - throws an error like "language is not defined" or something like that
      this.scope - how i writed in my post i dont have scope coz pages are in custom controllers so this.scope throws undefined

  • #3
    Do you have .tpl files for such pages?

    Comment


    • cossplay
      cossplay commented
      Editing a comment
      Yeah i have tpl files but if you mean to write something like {{ translate }} in tpl file i think this is same as this.getLanguage().translate and i need to take value from my custom file language

  • #4
    Uhm
    This works fine for me inside a .tpl file, it uses my custom scope for the translation.

    Code:
    {{translate 'someField' scope='CustomStat'}}
    Can you try this?
    Also are you using an API user or a normal user to request the json?

    Comment

    Working...
    X