-
Notifications
You must be signed in to change notification settings - Fork 198
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
Add i18n support with middleman features #1005
Conversation
Hi, very nice addon. Can this be adapted to show, for example, various versions of the same documentation? For example if I create a locale "v1", a locale "v2", will I be able to modify the content of all texts and examples? |
@musikele thank you for the comment. v1 and v2 can be used as locales themselves and you can change the texts based on each version, but for examples in lang. panes (shell, node, json...), my t(***) doesn't work correctly... basically i18n approach is designed for localization and if you want version control features, we'd better integrate slate original function. Code examples of each version should be managed in a different way by slate because it is not related to localization, but to API design itself. |
+1 I'd also like to use localization in our API docs at work. |
Hi, sorry for the delay in reviewing this PR! Unfortunately I can't merge this change into master, since a regex like this would break existing sites that have |
@lord Hi, thank you for your review and I understand your comment. Agree, this is a bit temporary patch with minimum code change and we'd better design the best way with minimum issues. I will make better idea and post it in wiki. |
@benzookapi My project need to support english and chinese. The index in index.zh.html.md.erb , _REST.md.erb and _Websocket.md.erb failed to list level two title in sidebar for chinese page,the default english page show right. likes I18t can not support chinese index? how to set up to support chinese index? ./locales ./source/include ./source/localizable |
Hey, this doesn't limit supported languages so Chinese should work.
This should be OK, make sure your yml has the following structure: en.yml
zh.yml
In my case, ./source/includes The files should have:
In my case, ./source/localizable
Under this structure, if you access to
if you access to
Hope this helps you. |
Hello, whether this plug-in is used for page switching or own language switching? I didn't attain the effect of language switching after following the steps? |
You need to activate middleman i18n, I followed this step. My config.rb has this line.
Hope this works for you. |
Hey wassup! I have followed the instructions but my keys are showing up as strings in the output. my config.rb file has this config: my file structure:
this is what I have in my MD file: en.yml:
fa.yml:
and this is the output in the browser: it seems that slate can't read and parse the translation files! |
@amirmeimari
Your structure seems wrong. If it's still not showing the text, try to remove |
I've changed the file structure and removed Is there any working example code that I can take a look at? |
I've fixed the issue. Thanks :) |
Hi @benzookapi , Seems it doesn't work for the files under
Result,
|
My source/includes/_errors.md works fine with these like 't(:note)'. (sorry I am not sure of "_intro.md") Your index.html.md works fine? |
@benzookapi |
Hello, t(:hello) is not interpreted Do I need to do something more ? |
It works fine. in config.rb, add this line: activate :i18n, :langs => [:zh, :en], :mount_at_root => :en in "_errors.md.erb" and "index.html.md.erb" , use the message <%=t(:errors)%> |
Hi, I would like to host our API docs as multilingual pages using middleman i18n features so made a small change to the source. Hope this change will contribute to others who have the similar needs so opening this pull request to base fork.
The following is how to i18n your slate sites.
Follow the middleman i18n steps, create the directory "localizable" under the "source" and move "index.html.md" there and create the directory "locales" under the root and put your target message files (e.g. "en.yml", "ja.yml"...) The details is: https://middlemanapp.com/advanced/localization/
(This is not included by my PR, done by users)
Embed "t(:YOUR_MESSAGE_KEY)" in index and other included .md files to where you want to i18n.
e.g.
index.html.md
title: t(:title)
--
en.yml
en:
title: "My Title"
--
ja.yml
ja:
title: "私のタイトル"
now you can see "My title" in "YOUR_URL/en" and "私のタイトル" in "YOUR_URL/ja". How you can manage the path for localization is fully controlled by middle man i18n above.
This localization is applied to HTML title and page content and footers.