This is a fork of https://github.com/rails/rails but it is only for updating the lastest files under guides/
and will never be merged back.
This is an experimental project that tries using generative AI to translate the Rails guide. The current results are:
- Taiwan's Traditional Chinese🇹🇼
- Lithuanian🇱🇹
- French🇫🇷
- Thai🇹🇭
- Brazilian Portuguese🇧🇷
- Simplified Chinese🇨🇳
It only has 2 new files.
guides/rails_guides/ai_translator.rb
: it's the main program.guides/ai_translate.rb
: it's the starting point
You can do the following steps if you want to play around with it.
- Set a new environment variable call
OPENAI_ACCESS_TOKEN
and set its value to your personal access token on OpenAI. - add a new language in
RailsGuide::AiTranslator
, for example,'jp' => 'Japanese'
- Open the terminal, go to
guides/
and start translating by executing
ruby ./ai_translate.rb jp
- You can also translate a single file, just add a filename after the command
ruby ./ai_translate.rb jp getting_started.md
- After all files are translated, you can just execute the rails existing script to generate HTML, CSS and JS. Unfortunately, it is likely to fail when you do that. Usually, it is because there are duplicated titles which lead to duplicated
id
in the HTML. You can fix it by finding out which title has the problem and can change that title a bit to avoid the problem. It can also have different problems when translating into different languages. Just try solving them so the process can finish.
bundle exec rake guides:generate:html GUIDES_LANGUAGE=jp
It is just an experimental project now. There are several issues that can be improved. If you think it is an interesting topic, feel free to discuss it with me.
The table of content is solved by disabling Turbo. However, there are anchor links spread among the articles. They cannot be converted to the correct URL smoothly, especially when it refers to an anchor on another page.
The Rails Guide has versions. A version is kind of a snapshot of the guide at a particular time. I haven't thought of a good way to manage them.
I'm now using gpt-3.5-turbo
. I live in Canada so I cannot use Google's Bard
. Feel free to change the code to be able to switch different models, like gpt4
or llamas 2
Epub files can be generated by the Rails guide script. However, it has errors when I want to import them into the Epub reader software, such as "Books" on OSX. I think it may related to the broken anchor links.
If you have any ideas that can make this project more sustainable, please discuss it with me. For example, it's a guide for Rails, why not build it as a Rails app?