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

[Feature Request] Add translation option to add language for Next and prev buttons. #43

Open
anvithks opened this issue Mar 21, 2023 · 4 comments

Comments

@anvithks
Copy link
Owner

I was wondering is there any option to add i18n translation to at least translate buttons next and previous. Of course I can try to do it on my own. I know I can hardcode this oj file, but you know that this approach is not something that I want to achieve. Besides adding a language file is much easier for average user.

Originally posted by @sysadmin-info in #24 (comment)

@sysadmin-info
Copy link

I was wondering is there any option to add i18n translation to at least translate buttons next and previous. Of course I can try to do it on my own. I know I can hardcode this oj file, but you know that this approach is not something that I want to achieve. Besides adding a language file is much easier for average user.

Originally posted by @sysadmin-info in #24 (comment)

The solution is quite simple. All you have to do is to create a i18n directory inside your plugin, where README.md is located. Then put inside the i18n directory file en.toml, pl.toml, fr.toml etc. for each language.

Example content of en.toml

[embed-pdf-next]
other = "Next"

[embed-pdf-prev]
other = "Previous"

Example content of pl.toml

[embed-pdf-next]
other = "Następna"

[embed-pdf-prev]
other = "Poprzednia"

Then in your file embed-pdf.html inside the shortcodes directory you have to change Next and Previous to this:

        <button id="pdf-prev-{{ substr (.Get "url" | md5) 0 8 }}">{{ i18n "embed-pdf-prev" }}</button>
        <button id="pdf-next-{{ substr (.Get "url" | md5) 0 8 }}">{{ i18n "embed-pdf-next" }}</button>

@anvithks
Copy link
Owner Author

Would you be able to raise a PR for this solution? I can test it out.

@sysadmin-info
Copy link

The problem is that I have no idea how to raise a PR. I already tested it on my side and it is working as expected.

@anvithks
Copy link
Owner Author

The problem is that I have no idea how to raise a PR. I already tested it on my side and it is working as expected.

Sure. No worries .
Let me check how it's done and will push these changes

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

2 participants