Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make strings in custom blocks translatable #1

Open
john-thomas-dotcms opened this issue Aug 21, 2023 · 0 comments
Open

Make strings in custom blocks translatable #1

john-thomas-dotcms opened this issue Aug 21, 2023 · 0 comments

Comments

@john-thomas-dotcms
Copy link
Collaborator

john-thomas-dotcms commented Aug 21, 2023

We need all strings in the custom blocks to be translatable into other languages.

We'll do this using dotCMS Language variables, which allow users to create different versions of the strings for different languages. We'll create the Language variables in the default language, using the English versions of the strings; if customers want translations in languages other than English, they can easily create them.

Making the strings translatable requires changes to both the plugin and the custom blocks.

Plugin

Implement new code to create Language variables for each of the strings, with a unique key for each string.

  • Language variables are a type of content in dotCMS.
    • So, this will mean making one method call for each string, to create the Language variable content for that string.
  • The code to create the Language variables should only be run if the Language variables don't already exist.
    • If the Language variables already exist, they should not be overwritten.
    • The code then will be a series of IF statements (or potentially a loop), one for each key (warning: bad pseudocode below):
            if {{key doesn't exist}}
                {{call method to create Language variable with the key and the default string}}
  • The code to create the Language variables will be hard-coded in the plugin (not changeable via the App).
    • The strings can be changed via the Language variables in the dotCMS back-end.

UI

Change all string retrieval to pull the strings based on the key, using the methods already identified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant