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

Update viewer.php #826

Closed
wants to merge 1 commit into from
Closed

Update viewer.php #826

wants to merge 1 commit into from

Conversation

ostasevych
Copy link
Contributor

Added localisation tags.

Add localisation tags.

Signed-off-by: Oleksa <ostasevych@users.noreply.github.com>
Copy link
Member

@danxuliu danxuliu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution!

However, please note that the PDF viewer uses a different translation system than other Nextcloud apps. The PDF viewer is based on the PDF.js project, and the localised strings in templates/viewer.php are provided by PDF.js rather than the PDF viewer app itself (templates/viewer.php is a slightly customized version of web/viewer.html from PDF.js). The localised strings are automatically translated when the PDF viewer is shown based on the data-l10n-id properties, so calling $l->t( is not needed to mark the string for extraction nor to translate them at runtime.

Note that this applies only to the templates/viewer.php file, and only to those elements that have a data-l10n-id property. Other strings, for example those defined in the JavaScript files specific to the PDF viewer, would use the standard translation system of Nextcloud. But, right now, there are no strings specific to the PDF viewer that need to be localised (although that will probably change soon).

Nevertheless, if you are interested in contributing to Nextcloud translations please check https://help.nextcloud.com/t/translation-knowledge-valid-for-the-entire-nextcloud-project-wiki/51550 Thanks a lot!

@danxuliu danxuliu closed this Oct 9, 2023
@ostasevych
Copy link
Contributor Author

Please, re-check! Having the strings translated in e.g. Ukrainian, the viewer is shown in English. Only after adding l-tags to the viewer.php and creating proper l10n/uk.json file I have managed to observe the menu in Ukrainian.

@github-actions
Copy link

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the reviewing process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR reviewing process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

@danxuliu
Copy link
Member

danxuliu commented Oct 23, 2023

Please, re-check! Having the strings translated in e.g. Ukrainian, the viewer is shown in English. Only after adding l-tags to the viewer.php and creating proper l10n/uk.json file I have managed to observe the menu in Ukrainian.

You are right, the translations do not honour the language specified in Nextcloud settings. The language is got from the browser preferences instead. I did not notice that because both languages were the same in my system :-)

It would be necessary to force PDF.js to use a specific language rather than auto-detecting it from the browser preferences. Unfortunately I have not been able to figure out how yet; I expected it to be just a matter of adding DFViewerApplicationOptions.set('disablePreferences', {LOCALE_CODE}) (where {LOCALE_CODE} would be the same set in Nextcloud settings) when the app is initialized, but that does not seem to work.

I will open an issue about that so it can be eventually fixed. My bad, I did not see that you had opened it in #834

@danxuliu danxuliu mentioned this pull request Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants