-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Support slug translations in the API docs #2404
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
Support slug translations in the API docs #2404
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2404 +/- ##
=======================================
Coverage 91.83% 91.83%
=======================================
Files 1 1
Lines 49 49
=======================================
Hits 45 45
Misses 4 4 Continue to review full report at Codecov.
|
Also, the duplicates slug |
Hmm, this PR actually would fix the slugs for API docs only, I haven't looked at /tutorial and /blog. If this is desirable we can then use |
@mindrones Happy to help :-) |
There are 3 options to go.
[1] based on the previous code (no dependencies, custom/simpler) I can clean up and squash depending on our preferences. |
I've been thinking a bit about this and maybe the best option would be to have the main website using To do this we should pass an environment variable, say export const makeSessionSlugProcessor = (preserveUnicode = false) => {
const processor = preserveUnicode ? unicodeSafeProcessor : limaxProcessor;
const seen = new Set();
return string => {
const slug = processor(string);
if (seen.has(slug)) throw new Error(`Duplicate slug ${slug}`);
seen.add(slug);
return slug;
}
} and in const makeSlug = makeSessionSlugProcessor(envPreserveUnicode); taking EDIT Implemented |
- implement a unicode-preserver processor and a latinizer processor via limax. The latinizer will maintain the case and the dollar sign so that we get anchors like: - #$set - #afterUpdate - #createEventDispatcher - config.js: - use SLUG_PRESERVE_UNICODE to true to build the site so that anchors in /docs preserve unicode chars (for languages like cyrillic) (see test/utils/slug.js) - use SLUG_SEPARATOR to easily update slugs in /docs - use SLUG_LANG to set up the language to translate unicode symbols in anchors: - de: 'Ich ♥ Deutsch' -> 'ich-liebe-deutsch' - en: 'Ich ♥ Deutsch' -> 'ich-love-deutsch' Fixes #2344
Fixes #2344
I tried some of the libraries investigated by @Ryuno-Ki here #2344 (comment).
I find limax quite good:
lang
option that in the future might be handy for i18n (if you don't specify it, it tried to auto detect the language);$
from being sustituted withusd
, useful for$set
and friends).Here are some screenies: