picocms / Pico

Pico is a stupidly simple, blazing fast, flat file CMS.
http://picocms.org/
MIT License
3.82k stars 616 forks source link

GetText Support #465

Closed anasram closed 5 years ago

anasram commented 5 years ago

Are you planning to support gettext (or any alternative solution for multilingual strings) in Pico?

I think such a feature is very essential in any CMS nowadays.

PhrozenByte commented 5 years ago

There are no plans to add this to Pico's core. Anyway, one of Pico's main strengths is its extensibility using plugins and its extensive event system. There are indeed plans to create a official i18n plugin with Pico 3.0 (see #317), however, due to very limited time, this probably isn't going to happen soon.

However, you actually don't really need a i18n plugin to create a multilingual website. The easiest solution is to create corresponding subfolders in your content directory (e.g. content/en, content/de, content/jp, …) and duplicate the contents. With a appropriate .htaccess RewriteRule you can redirect requests to your index page (i.e. http://example.com/pico/) to the appropriate language subdirectory (e.g. http://example.com/pico/en/). In addition, you should extend your theme to provide a language selector. Fixed strings in your theme can be replaced by simple YAML-based language files (e.g. config/lang.yml), that can be used with {{ config.lang.some_string }} in Twig. You can use a Twig macro or a small Twig function to shorten the syntax (including the well known gettext _ alias).

anasram commented 5 years ago

The easiest solution is to create corresponding subfolders in your content directory...

You're talking here about multilingual content. For this propose I already use Multi-language plugin, thanks to @TilBoerner.

Whilst I'm talking about multilingual UI, which means multi-language support in Twig templates themselves.

In addition, you should extend your theme to provide a language selector. Fixed strings in your theme can be replaced by simple YAML-based language files...

This is exactly what I'm talking about. Unfortunately, I'm not a PHP expert, may @TilBoerner be interested in adding such a feature to his plugin?

Lomanic commented 5 years ago

@tilboerner plugin is not updated since 5 years, I think you should use this fork which has been ported to Pico v1 and shows how to change the site title (a twig variable) depending of the locale. You could then extend it to your own defined variables to be used in your twig templates.

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in two days if no further activity occurs. Thank you for your contributions! :+1:

anasram commented 4 years ago

By releasing version 3.0.0-alpha.1, I hope I can I refresh my hope for seeing Pico with multilingual UI support! ⏳ 🌞

BTW, I wish also If you could recommend an up-to-date Multi-language plugin in your official Pico Plugins.