Skip to content

[i18n_subsites] Allow merging the base settings with the translations settings. - #1350

Open
adiroiban wants to merge 2 commits into
getpelican:masterfrom
chevah:i18n-dict-merge
Open

adiroiban wants to merge 2 commits into
getpelican:masterfrom
chevah:i18n-dict-merge

Conversation

@adiroiban

@adiroiban adiroiban commented Sep 26, 2021

Copy link
Copy Markdown

To help organize the translations any text from pelicanconf.py that is presented on the site is put in a common dictionary

The idea is that if you add a new value in the default site and that site is not translated, it will be present in the translated site using the default language....similar to gettext.


Instead of using a simple copy with overwriting of root dict keys I went with a simple dict merge code.

I have simplified the tests.

to run the tests

virtualenv venv
. venv/bin/activate
pip install pelican
python -m unittest i18n_subsites/test_i18n_subsites.py

An example

L10N = {
    'author': 'Pro:Atria Team',
    'company': 'Pro:Atria Ltd',
    'company_number': '4213930',
    'product': 'SFTPPlus',
    'email': {
        'contact': 'contact@proatria.com',
        'sales': 'sales@proatria.com',
        'support': 'support@proatria.com',
        },
    'menu': [
        # Text, URL, category.
        ('Product', '/product/', 'product'),
        ('Support', '/support/', 'support'),
        ('Contact', '/about/contact.html', 'contact'),
        ],
    }

I18N_SUBSITES = { 'de': 'L10N': {
    'company': 'Pro:Atria Ag',
    # The other emails are kept as in the main site.
    'email': {'sale': 'sales@proatria.de'},
    'menu': [
        # Text, URL, category.
        ('Produkt', '/de/product/', 'product'),
        ('Support', '/de/support/', 'support'),
        ('Kontakt', '/de/about/contact.html', 'contact'),
        ],
}}

@adiroiban

Copy link
Copy Markdown
Author

I also have a patch to translate the values from pelicanconf.py using gettext.

But I think that this patch is still valid for people who don't want to use gettext

@georgkrause

Copy link
Copy Markdown

@adiroiban Mind filing the same against my fork at https://github.com/georgkrause/i18n_subsites ?

rschiang added a commit to rschiang/pelican-plugins that referenced this pull request Aug 9, 2022
[i18n_subsites] Allow merging the base settings with the translations settings.
rschiang added a commit to rschiang/pelican-i18n-subsites that referenced this pull request Aug 9, 2022
…ict-merge

[i18n_subsites] Allow merging the base settings with the translations settings.
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.

2 participants