Skip to content
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

🌐 feat(i18n): add Persian language #283

Merged
merged 6 commits into from
Mar 1, 2024
Merged

🌐 feat(i18n): add Persian language #283

merged 6 commits into from
Mar 1, 2024

Conversation

mehr32
Copy link
Contributor

@mehr32 mehr32 commented Mar 1, 2024

Summary

This is a request to add Farsi language translation to the template. The translation is complete but I still couldn't solve the unsupported language error? :/ Please test it

Related issue

Persian translation added

Changes

Accessibility

I have set the language to fa-IR in the config file, but I get an unsupported language error

Type of change

  • Bug fix (fixes an issue without altering functionality)
  • New feature (adds non-breaking functionality)
  • Breaking change (alters existing functionality)
  • UI/UX improvement (enhances user interface without altering functionality)
  • Refactor (improves code quality without altering functionality)
  • Documentation update
  • Other (please describe below)

Checklist

  • I have verified the accessibility of my changes
  • I have tested all possible scenarios for this change
  • I have updated theme.toml with a sane default for the feature
  • I have made corresponding changes to the documentation:
    • Updated config.toml comments
    • Updated theme.toml comments
    • Updated "Mastering tabi" post in English
    • (Optional) Updated "Mastering tabi" post in Spanish
    • (Optional) Updated "Mastering tabi" post in Catalan

@mehr32 mehr32 requested a review from welpo as a code owner March 1, 2024 08:12
@mehr32
Copy link
Contributor Author

mehr32 commented Mar 1, 2024

Also, the whole format should be RTL in Farsi language
How should this be done?

@mehr32
Copy link
Contributor Author

mehr32 commented Mar 1, 2024

I think I found the solution.
To display right-to-left texts correctly, it should be in templates/page.html
Line 56 is as follows:

 article dir="auto">

change it.
But I don't have any idea to turn the entire template from right to left

@welpo
Copy link
Owner

welpo commented Mar 1, 2024

Hello!

Thank you for contributing the translation!

Unless necessary, we use the two letter code (ISO 639-1). Thus, the file should be fa.toml.

This will fix the RTL issue. For context, tabi sets the reading direction based on some hardcoded language codes. You can see this in the base.html template:

tabi/templates/base.html

Lines 16 to 26 in 4aaa234

{% set rtl_languages = ["ar", "arc", "az", "dv", "ff", "he", "ku", "nqo", "fa", "rhg", "syc", "ur"] %}
<!DOCTYPE html>
<html lang="{{ lang }}" {% if config.extra.default_theme -%}
data-theme="{{config.extra.default_theme}}"
{%- endif -%}>
{% include "partials/header.html" %}
<body{% if lang in rtl_languages %} dir="rtl"{% endif %}>

I have set the language to fa-IR in the config file, but I get an unsupported language error

This error, right?

Error: Tried to build search index for language fa-IR which is not supported

All this means is that Zola (not tabi) does not support search for this language. You can test your changes by setting build_search_index = false.


Could you please rename the file, test everything looks good on your end, and let me know so I can merge?

Thank you!

@welpo welpo changed the title add fa-IR 🌐 feat(i18n): add Farsi language Mar 1, 2024
@welpo welpo changed the title 🌐 feat(i18n): add Farsi language 🌐 feat(i18n): add Farsi language Mar 1, 2024
@welpo welpo added enhancement New feature or request i18n Internationalisation labels Mar 1, 2024
i18n/fa-IR.toml Outdated Show resolved Hide resolved
@mehr32
Copy link
Contributor Author

mehr32 commented Mar 1, 2024

does not support All this means that Zola (not tabi) the search for this language. You can test your changes by setting build_search_index = false.
ommm erorr :

Error: Failed to build the site
Error: Failed to render section '/home/mehr32/blog/content/archive/_index.md'
Error: Reason: Failed to render 'archive.html'
Error: Reason: Filter call 'date' failed
Error: Reason: Error parsing fa as a locale

@welpo welpo changed the title 🌐 feat(i18n): add Farsi language 🌐 feat(i18n): add Persian language Mar 1, 2024
@welpo
Copy link
Owner

welpo commented Mar 1, 2024

Error: Reason: Failed to render 'archive.html' Error: Reason: Filter call 'date' failed Error: Reason: Error parsing fa as a locale

This should be fixed by setting date_locale = "fa_IR" in fa.toml, instead of date_locale = "fa".

@welpo
Copy link
Owner

welpo commented Mar 1, 2024

I've added the fix and updated the docs. Merging now.

Many thanks for contributing to tabi!

@welpo welpo merged commit 9a5ea8e into welpo:main Mar 1, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request i18n Internationalisation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants