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

Error pages now translated in 🇫🇷 #82

Merged
merged 2 commits into from
Mar 28, 2022
Merged

Error pages now translated in 🇫🇷 #82

merged 2 commits into from
Mar 28, 2022

Conversation

jturazzi
Copy link
Contributor

Description

Changed

  • Error pages now translated in 🇫🇷

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I wrote unit tests for my code (if tests is required for my changes)
  • I have made changes in CHANGELOG.md file

@codecov
Copy link

codecov bot commented Mar 28, 2022

Codecov Report

Merging #82 (14b4e6f) into master (4a918b1) will decrease coverage by 0.30%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master      #82      +/-   ##
==========================================
- Coverage   42.90%   42.59%   -0.31%     
==========================================
  Files          32       32              
  Lines        1296     1296              
==========================================
- Hits          556      552       -4     
- Misses        705      710       +5     
+ Partials       35       34       -1     
Impacted Files Coverage Δ
internal/tpl/render.go 71.75% <0.00%> (-3.06%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fac7394...14b4e6f. Read the comment docs.

Copy link
Owner

@tarampampam tarampampam left a comment

Choose a reason for hiding this comment

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

You've done a tremendous job! Thank you!

@tarampampam tarampampam merged commit 481e11d into tarampampam:master Mar 28, 2022
@tarampampam
Copy link
Owner

tarampampam commented Mar 28, 2022

@jvin042 v2.12.0 released! Please, check on your side after a few minutes (when the CI process is completed)

@jturazzi
Copy link
Contributor Author

jturazzi commented Mar 28, 2022

@tarampampam idiot question, how do you put the language ? I did not find. I'm use docker-compose and traefik.

The language detection does not work. I'm test Ghost et Connection template.

@tarampampam
Copy link
Owner

tarampampam commented Mar 28, 2022

@jvin042 this is a normal question :) The details are described here:

This directory contains file [l10n.js](l10n.js) for the error pages localization. The working logic is very simple - pages load this script using [jsdelivr.com](https://www.jsdelivr.com/) as a CDN for [versioned content from the GitHub repository](https://www.jsdelivr.com/features#gh), and it translates tag content with the special HTML attribute `data-l10n`.

Also, each template loads the l10n.js file like this:

if (navigator.language.substring(0, 2).toLowerCase() !== 'en') {
((s, p) => { // localize the page (details here - https://github.com/tarampampam/error-pages/tree/master/l10n)
s.src = 'https://cdn.jsdelivr.net/gh/tarampampam/error-pages@2/l10n/l10n.min.js'; // '../l10n/l10n.js';
s.async = s.defer = true;
s.addEventListener('load', () => p.removeChild(s));
p.appendChild(s);
})(document.createElement('script'), document.body);
}

So, if your browser locale !== 'en' - the script will localize all required messages automatically.

Opened question is a cache lifetime on the jsdelivr side (I have found this explanation about the caching strategy) - I am currently looking for ways to clear the cache manually.

@jturazzi
Copy link
Contributor Author

image

The translation does not seem to be loaded. I'll look at it tonight to try it out more :)

@tarampampam
Copy link
Owner

https://cdn.jsdelivr.net/gh/tarampampam/error-pages@2/l10n/l10n.min.js at this moment contains outdated content (without the fr locale) - I am currently looking for ways to reset the cache manually

@tarampampam
Copy link
Owner

Automatic cache refreshing can takes about 12 hours. So, we can only have one option for now - wait for tomorrow ;)

@jturazzi
Copy link
Contributor Author

Yes it is :) Thanks you :)

image

@tarampampam
Copy link
Owner

tarampampam commented Mar 28, 2022

I have found the solution. Please, purge the cache in your browser and try again.

Curl example for a checking:

$ curl -s https://cdn.jsdelivr.net/gh/tarampampam/error-pages@2/l10n/l10n.min.js | head -c 499
/**
 * Minified by jsDelivr using Terser v5.10.0.
 * Original file: /gh/tarampampam/error-pages@2.12.0/l10n/l10n.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
Object.defineProperty(window,"l10n",{value:new function(){const e={Error:{fr:"Erreur",ru:"Ошибка",uk:"Помилка"},"Good luck":{fr:"Bonne chance",ru:"Удачи",uk:"Успіхів"},"UH OH":{fr:"Oups",ru:"Ох",uk:"Ох"},"Request details":{

@jturazzi
Copy link
Contributor Author

@tarampampam I confirm that it works ! 😉

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

Successfully merging this pull request may close these issues.

None yet

2 participants