Skip to content

feat: Add i18n support.#362

Merged
fgmacedo merged 1 commit intodevelopfrom
macedo/i18n
Mar 4, 2023
Merged

feat: Add i18n support.#362
fgmacedo merged 1 commit intodevelopfrom
macedo/i18n

Conversation

@fgmacedo
Copy link
Copy Markdown
Owner

@fgmacedo fgmacedo commented Mar 4, 2023

Add support for internationalization, translating the messages into pt_BR as an example. Closes #19.

Add a translation

Extract a Portable Object Template (POT) file:

pybabel extract statemachine -o statemachine/locale/statemachine.pot

Then, copy the template as a .po file into the target locale folder. For example, if you're adding support for Brazilian Portuguese language, the code is pt_BR, and the file path should be statemachine/locale/pt_BR/LC_MESSAGES/statemachine.po:

cp statemachine/locale/statemachine.pot statemachine/locale/pt_BR/LC_MESSAGES/statemachine.po

Then open the statemachine.po and translate.

After translation, to get the new language working locally, you need to compile the .po files into .mo (binary format). Run:

pybabel compile -d statemachine/locale/ -f statemachine.po

On Linux (Debian based), you can test changing the LANGUAGE environment variable.

# If the last line is `Can't guess when in Won.` something went wrong.
LANGUAGE=pt_BR python tests/examples/guess_the_number_machine.py

Then open a pull request with your translation file.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Mar 4, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 4, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change

Comparison is base (5b2b511) 100.00% compared to head (77d2ab0) 100.00%.

Additional details and impacted files
@@            Coverage Diff            @@
##           develop      #362   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           18        19    +1     
  Lines          919       924    +5     
  Branches       153       153           
=========================================
+ Hits           919       924    +5     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
statemachine/utils.py 100.00% <ø> (ø)
statemachine/callbacks.py 100.00% <100.00%> (ø)
statemachine/dispatcher.py 100.00% <100.00%> (ø)
statemachine/exceptions.py 100.00% <100.00%> (ø)
statemachine/factory.py 100.00% <100.00%> (ø)
statemachine/i18n.py 100.00% <100.00%> (ø)
statemachine/state.py 100.00% <100.00%> (ø)
statemachine/statemachine.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@fgmacedo fgmacedo marked this pull request as ready for review March 4, 2023 20:46
@fgmacedo fgmacedo merged commit 1cef155 into develop Mar 4, 2023
@fgmacedo fgmacedo deleted the macedo/i18n branch March 4, 2023 20:56
@fgmacedo fgmacedo changed the title feat: Add i18n support. Closes #19 feat: Add i18n support. Mar 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for i18n

1 participant