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

[PR] Gh pages Localization structure #426

Closed
wants to merge 5 commits into from

Conversation

jamjan
Copy link

@jamjan jamjan commented Sep 10, 2019

Localization for slimphp/Slim-Website (gh-pages)

Changes

New variables

Templates now have two new front-matter variables in use:

  • l10n-link - utilized in _includes/languages.html to determine if same content is available in other languages. If there is corresponding document in different languages then the flags will be diplayed. The convention is to use <directory_name>-<version>-<filename> where hyphens in filename are replaced with underscores. i.e. variable l10n-link in document in section 'Concepts' for version 4 with filename 'dependency-injection.html' would have value concepts-v4-depency_injection
  • l10n-lang - determines documents language. The default should be en.

_config.yml changes

Two new variables are present in the _config.yml file:

  • l10nDefaultLang - determines default language of the website. default value is en.
  • l10nLanguageLabels - is an array which has language code as index and name as value.

New templates

Language switcher in included in new template _inlcudes/languages.html which is included from _includes/header.html.

Changes to existing *.html files

  • added liquid variables l10n-link and l10n-lang to every *.html file in docs directory, /blog/index.html and contribute/index.html.

How to use it

Directory structure

Content in language other than the l10nDefaultLanguage should be stored in the {{lang}} directory on the Application level.

<root>
    - _layouts/
        (...)
        - docs-v3.html
        - docs-v4.html
        - pl/ <-- language specific layouts
            - default.html
            - docs-v3.html
            - docs-v4.html       
        - fr/ <-- language specific layouts
            - default.html
            - docs-v3.html
            - docs-v4.html
    (...)
    - pl/ <-- language specific content
        - blog/
            - index.html
        - contribute/
            - index.html
        - docs/
            - start/
                - index.md
                - installation.md
            - index.md
        index.html
    - fr/ <-- language specific content
        - blog/
            - index.html
        - contribute/
            - index.html
        - docs/
            - start/
                - index.md
                - installation.md
            - index.md
        index.html

Config changes

In order to add new language

  • the sections should be duplicated changed path index. i.e. path: "pl/docs/v4" or path: "fr/docs/v4".
  • Those section-items which does not have translation should have value of l10nDefault language as the fallback.
    • in example:
    docs-v4:
      - title: Zaczynamy
        items:
          - [/pl/docs/v4, Rozpocz&#281;cie]
          - [/pl/docs/v4/start/installation.md, Instalacja]
          - [/docs/v4/start/upgrade.md, Aktualizacja, en]
          - [/docs/v4/start/web-servers.md, Serwery Web, en]
          - [/docs/v4/deployment/deployment.md, Wdro&#380;enie, en]

First two sections will redirect to translated content where other will redirect to the default language page.

** Note ** This is utilized in sidebar for user-guide. If localized content is not available then the flag for the l10nDefaultLang will be displayed.

Other Notes

Flags (images)

You can download the country flag from Famfamfam page and save your image file into ./assets/images/flags/

Learning jekyll? Try these:

Useful links:

Issues with Jekyll

Custom plugins are just not working. Tried to use on Ubuntu18 but no luck. Seems to be Jekylls thing.
As an effect plenty of logic tasks are solved in templates.

Issue with plugins. None of the three methods described worked.

TODO

  • Search functionality in other languages than English.

@jamjan jamjan changed the title Gh pages Localization structure {WIP] Gh pages Localization structure Sep 10, 2019
@jamjan jamjan changed the title {WIP] Gh pages Localization structure [WIP] Gh pages Localization structure Sep 10, 2019
@jamjan jamjan changed the title [WIP] Gh pages Localization structure Gh pages Localization structure Sep 10, 2019
@jamjan jamjan mentioned this pull request Sep 11, 2019
_config.yml Outdated
@@ -8,7 +8,10 @@ slim_docs_versions: v2, v3, v4
slim_website_repo: https://github.com/slimphp/Slim-Website/tree/gh-pages/
urlBasePath:
include: [.htaccess]
exclude: [node_modules]
exclude: [node_modules,.idea]
l10nDefaultLang: gb
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be en instead of gb?

_config.yml Outdated
@@ -298,3 +299,18 @@ defaults:
type: "pages"
values:
layout: docs-v2
t:
blog:
gb: "Blog"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gb should be en for all occurrences below

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as of country/language codes I have a table published there https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2

With such a naming convention we should use English flag rather that GB.

in case of Brazil-Portuguese we would go for br rather that for pt.

Also, the gb goes nicely with famfamfam flag naming

Shall I change it anyway?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should change this to en. See https://en.wikipedia.org/wiki/ISO_639-1. This is a language and not a region (country) after all.

@l0gicgate
Copy link
Member

@adriansuter this looks good to me.

@jamjan jamjan changed the title Gh pages Localization structure [PR] Gh pages Localization structure Sep 23, 2019
@l0gicgate
Copy link
Member

@janfkowalski I built the branch on the dev server and there's a bug on the front page. The label "Community" does not show up.

See http://slim-website.lgse.com/

support:
en: "Support"
community:
gb: "Community"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you forgot to change this label to en: "Community"

@jamjan jamjan mentioned this pull request Sep 25, 2019
@l0gicgate
Copy link
Member

Follow in #432

@l0gicgate l0gicgate closed this Sep 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants