Translating CircuitVerse Into Different Languages
CircuitVerse Main platform is written in Ruby on Rails and requires the use of Rails i18n for internationalization. For more have a look at I18n technical Documentation.
For localization Rules to be used in the Rails platform, kindly visit I18n Localization Rules
Adding support for a new language is easy and can be done following below steps -
- Locate the translation directory of a module to be translated.
- Create a
.yml
translation file for a new language. - copy and edit existing YAML templates for a new language.
Below is the detailed guide for the same.
For locating the translation directory and corresponding YAML template for the particular module, We advise contributors to know a little more about the design of the directory structure before adding support for the new language. Here
We follow the exact top-level directory structure for translations in the config/locale/
folder as followed by codebase.
Eg. app/views/logix/<ruby_template_files>
will have translations stored at config/locale/views/logxi/<yml_files>
In a very simple manner, you can copy a particular string present on the page and use the Search tab of your editor to reach the corresponding YAML file belonging to that page.
Or else you can locate the ERB template for the particular page in the app/views/
directory and you see the exact structure in the config/locale/
directory to reach the corresponding translation file.
We already possess I18n infrastructure for the languages like English and Hindi. Following the same infrastructure I18n for a new language shall be introduced.
After locating the translation directory following steps can be followed to begin with translations -
-
Find the locale of the language for which you are providing support. Here
-
If language is not in the list of supported locale
-
add locale value in the list of supported locales
In config/application.rb
config.i18n.available_locales = [:en, :hi]
-
-
Create template file in respective directory as
locale.yml
(eg. zh.yml). A restart of the server is required every time a new YAML template is created -
Copy content of
en.yml
into the newly created template file. -
Replace top-level namespace
en:
to the desired language locale (zh:
) and replace English translation strings with the desired one.
A similar guide can be followed for other modules such as controllers, models, forms etc
After adding YAML files and feeding translations for a new language, A restart of the locale Rails Server is recommended.
We can switch language using locale
field present in User's Dashboard --> Edit Details
to see results in the desired language
-
Part of a string contains Instance Variables
Some of the strings can have instance variables included in them. Here we use Rails I18n interpolation.
YAML hello %{user_name}
Any string inside
%{}
(hereuser_name
) are interpolated variables and need not be translated but should be taken with the string as some language that flows from right to left can alter the position of instance variables. -
Similarly, if part of a string contains links and HTML tags, they should be taken with the string as it is and care shall be taken when localizing them as in any different language their position may alter.
-
Forms attributes shall be localized according to the rules mentioned here. Form templates can also contain strings that are not the form attributes such strings shall be included in respective YAML files present
views
directory and in relevant namespace. -
Links generated using
_path
or_url
Rails helpers should be localized using interpolation techniques so that links don't get separated from the stringBefore
You don't have any projects. Create one <%= link_to 'here', simulator_new_url, class: 'anchor-text' %>
After
<%= t("core_key_name", simulator_new_url: link_to(t("link_key_name"), simulator_new_url, class: 'anchor-text') )%>
CircuitVerse is a web-based simulation software for creating and testing digital circuits. The easy drag and drop feature makes it easier and a fun way to learn about logic circuits and also compatible to be used by teachers as well as students. From simple gates to complex sequential circuits, plot timing diagrams, automatic circuit generation, explore standard ICs, and much more, CircuitVerse has got you covered. It also lets the user store and access the previously built circuits to build yet more complex circuits and generate truth tables for the constructed circuits.
- Home
- Running the server
- Simulator
- Development
- Internationalization (I18n)
- GSoC '19
- GSoC '20
- GSoC '21
- GSoC '22
- GSoC '23
- GSoC '24
- GCI 2019
- Google Season of Docs 2020