Closed TomPichaud closed 10 years ago
Hi @TomPichaud nice idea. I think you could create a folder for each language in the root folder. e.g.
content/en/about.md
content/en/index.md
content/fr/about.md
content/fr/index.md
the meta information for the lang
attribute could be set in each file.
What do you need now is a plugin which guess the right language an make a redirect at the first time.
Maybe a second plugin which create a language switcher.
I was literally going to suggest the same thing as @NeoBlack
I'll try my best to do it and share it with the community ! I know you and others will optimize my code ;) I think I'll finish it for the weekend.
@NeoBlack maybe a sessions plugin combined with a redirect plugin could be a good combo?
I think it would be better to keep the translations with the content myself and therefore rather than have the language stuff in a separate folder I would have it in the same folder but with extra extensions.
For example:
content/about.md
content/about.de.md
content/about.fr.md
content/index.md
content/index.de.md
content/index.fr.md
This ensures that contents stays together and it is easier to update several versions of a file together rather than having to start from the top again.
It should also mean that that the work needed to find a translation is much easier.
When an about page is requested the plugin can look to see if the user has a language preference in their incoming request, or in a cookie if so then translations can be sought if none found for the language code then the default page is displayed. So in this case users who request French (fr) or German (de) versions be given a translated version.
Another advantage of this approach is further variations can be provided for languages e.g. About.en_GB.md could have British English, about.fr_CA.md could have Canadian French, but the specifics don't have to be provided every time. When a user requests a fr_CA version the system should first check if one is available then fallback to a fr version and then finally fallback to the default version.
Yeah that's better but I'm no web developer, so I wouldn't know how to do it properly... I'm not even sure I can do it, I suggest @NeoBlack or @james2doyle to build a sessions plugin combined with a redirect plugin
then maybe I could easily build a MultiLingual plugin over it.
Also, nowadays most website are MultiLingual any cms provide this feature so why not integrate it directly into Phile ?
Maybe a new constant for the language is in order? Default would be blank, and then that constant could affect the markdown file name:
// LANG == ".fr"
$file = "un-petit-chat".LANG.".md"
I agree with you, that multi language support is a feature for the core, but we would implement it as a core plugin. The main idea is, to have a really small core, and feature has to be implemented in plugins.
@james2doyle what is about pages with different language versions, like us-en and gb-en ? Your idea is great, we could use the lang id in the filename, but we should implement flexible, so not with a fix length of language key. On the other side, I think setting this information in the path is also possible, like my examples. Currently I am not sure what is the best way. Lets do a little bit more brainstorm about it.
Actually, you could do my idea right now with a sessions plugin. All you need to do is modify the CONTENT_EXT
global constant. Then you could have a sessions plugin that could run a function, that changes the constant, via a form submission or something.
// french is the default language of this site
define("CONTENT_EXT", ".fr.md");
ok, what happens if a page has no translation? we need a fallback but CONTENT_EXT is a constant. Also, how trigger this in the URL? /about can only be used for one language. because we need different urls, we could receive the language key from URL to find all pages in the given language.
I would prefer to define a new constant like CONTENT_LANGUAGE
and if it is set use it in combination with CONTENT_EXT
to find the right pages, like this $file = $filename . CONTENT_LANGUAGE . CONTENT_EXT
Yeah my example was quick and dirty and would require all markdown pages to be assigned a language. I agree that it isn't good, but quick and dirty never means to be.
— Sent from Mailbox for iPhone
On Tue, Nov 19, 2013 at 5:38 PM, Frank Nägler notifications@github.com wrote:
ok, what happens if a page has no translation? we need a fallback but CONTENT_EXT is a constant. Also, how trigger this in the URL? /about can only be used for one language. because we need different urls, we could receive the language key from URL to find all pages in the given language.
I would prefer to define a new constant like
CONTENT_LANGUAGE
and if it is set use it in combination withCONTENT_EXT
to find the right pages, like this$file = $filename . CONTENT_LANGUAGE . CONTENT_EXT
Reply to this email directly or view it on GitHub: https://github.com/PhileCMS/Phile/issues/26#issuecomment-28843539
Hi, I guess i'll be able to do my multilingual plugin now, but may I have some documentation please ? (I'm learning for my exams [20th dec] so do not expect my plugin to be out before christmas) Thanks
Any updates on this?
I'm still on the side of having a second site with different content. Since almost everything needs to be translated, including plugins, and the config as well.
Maybe if there was a separate multilingual version of Phile, that could be an idea.
For myself, I have next idea: on the site-root there are folders with proper languages, like |-/ |-- en |-- fr |-- de |-- ...
Also, this folders have the same structure. With solution from #51 , you can list articles for only one selected language, like site.com/en/
or create in articles links, like read this article on [ en | fr | de | .. ]
and route to proper url, by replacing, for example, /en/
to /de/
in URL (simple Twig plugin).
As for me, I think, I will be toо lazy to translate articles on all languages, so this solution has the right to life :D
What about "automatic correct language", you can look at browser's accept-languages and select first one, by constructing proper URL.. But I think it's waste of time :)
yeah that is a version of @NeoBlack comment
You can actually do the following:
// split all config items into language key => values
$config['site_title'] = array(
'en' => 'Hello',
'fr' => 'Bonjour'
);
Once you set a Lang
meta in your page, then Twig can do something like:
<title>{{ config.message[meta.lang] }}</title>
So if you were in example.com/en/index
it would be "Hello". And if you were in example.com/fr/index
it would be "Bonjour".
Oh, yup, I forget :D Exactly! Looks like it's the simplest solution. :)
I think we may take a look at Pico multilanguage plugin
Im going to close this. Seems like a feature of the core or possibly some smart plugin.
Hi everyone, hope everything is fine for you ! While finalizing my website I'm thinking why not publish it in French too, but how would I integrate this in Phile... I was thinking something like this
I'm no web developer but I think that would be the easiest, fastest way to do it no ?
Would you integrate this in Phile ? or make a plugin ? Please :)
Thanks