Languages and alternative language support ⇒ i18n - l10n (languages) ⇒ Default Language ⇒ Community Forums ⇒ CPG Dragonfly™ CMS
Forum Indexi18n - l10n (languages)

Default Language Reply to topic


As I understand multi-lingual support I can set the language for most things I add to my site and if a user has selected a certain language then they will appear to that user if they are in their selected language, or if they are set to default.

What I ideally want to do is to serve up content based on a user's language selection or, if there is no content for that language, to then serve up the default content.

So if I have a welcome message in say, English and French, if someone comes to the site with German selected they get the English version, as there is no German version. However, if they have French selected, they get the French version only, not the English version.

Is that possible?

If that makes sense!

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):


In News and Pro_News it works as follows:
  • iff (if & only if) Story/Article is in same language as user selected then it is displayed
  • if a version marked 'All' is present then it is always displayed regardless of user selection.

So ... I would assume that if English, let's say, was your default language and French was available, but German not, then you could post 2 copies of every Story/Article, an English version marked 'All' and a French version marked 'French'.

This would work, except the French user would see both versions.

If, alternatively, you set the English version to 'English' instead of 'All' then the German user would see nothing.

So it appears to me that the system is binary: for any given Story/Article you publish either:
  • Once and mark it 'All', or
  • One copy for each and every language and mark each for each language.

That would imply that you have to (re-)publish 'English' Stories/Articles marked as 'German' - even if it is still in English - to get the result you desire. I could be wrong...

Have no clue about other modules.

Pro_News CM™ - Content Management for Dragonfly CMS™

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux / 1.3.39 - 2.4.9 / 5.5.42 - 5.6.16 / 5.4.37 - 5.5.11 / 9.4


News does lookup for articles based on user language preferences as well, same as above, and fall back to english is none found.

.:: I met php the 03 December 2003 :: Unforgettable day! ::.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
CloudLinux / Apache 2.4 LSAPI / MySQLi 5.6 / PHP 5.6 / DCVS


LB,

That sounds like the best way around it - just publish in English again if I don't have a german equivalent.

Nano,

When you say News falls back to English if none is found, do you mean it falls back to 'All' as a language selection?

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):


Not even the therm "falls back" is correct.
With multi language enabled, users will read articles in their language + any article with "all" as language, if any of those are found.

.:: I met php the 03 December 2003 :: Unforgettable day! ::.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
CloudLinux / Apache 2.4 LSAPI / MySQLi 5.6 / PHP 5.6 / DCVS


That's what I thought. LB's solution will work for me, although it means having to submit everything 6 times!

LB - I notice that I can't submit an article if it has the same title as another - so I guess that means I have to at least translate that each time. Was that intentional?

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):


rosbif wrote
LB - I notice that I can't submit an article if it has the same title as another. Was that intentional?


Not really, I suspect that it's the result of a check that Masino Sinaga added to remove the risk of someone accidentally inserting the same record twice due to double clicking (on a slow connection).

You may just want to comment that double entry check out - perhaps just on the Admin side. You can find it easily enough by searching on "Masino Sinaga".

Back to the original problem, it ought to be easy to just mod the code to do what you want. It is only implemented this way because people asked for same functionality as News. But need to change: $sql .= ($multilingual ? " AND (alanguage='$currentlang' OR alanguage='')" : '');
to not return the '' (All) version if a '$currentlang' option is present. A non-trivial piece of SQL code - to me anyway. Smile

Pro_News CM™ - Content Management for Dragonfly CMS™

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux / 1.3.39 - 2.4.9 / 5.5.42 - 5.6.16 / 5.4.37 - 5.5.11 / 9.4

Last edited by layingback on Sat Mar 05, 2011 1:20 pm; edited 1 time in total


Thanks LB. I've added the articles for each language now for my welcome message. Would need to have a think about how to implement it otherwise - it would have to check if it was multilingual, if so then it would display articles set to no language and to the selected language, but if it found none it would display the default language (ie English for me). Or something...

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):


I was looking at it the wrong way, I think it is just a case of looking for:

$multilingual

This should turn up many lines some of which look similar to but not necessarily the same as the samples below (differences is in the parentheses, single/double quotes and order of the operands): $sql .= ($multilingual ? " AND (alanguage='$currentlang' OR alanguage='')" : '');
or
$sql .= ($multilingual) ? ' AND (alanguage="" OR alanguage="'.$currentlang.'")' : '';


Change all such lines to read:
$sql .= $multilingual ? ' AND (alanguage="'.$currentlang.'" OR (!alanguage="'.$currentlang.'" AND alanguage=""))' : '';

That is if user language version exists choose it, or if it doesn't exist but an All version does return it.

NOTE that I've not tested this, as it will take some time for me to set up a test environment. As you already have a setup, do you want to test for me, please, and if it works, I'll publish the list of modules which can be changed (as it should work for News, etc., too). TIA!

Pro_News CM™ - Content Management for Dragonfly CMS™

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux / 1.3.39 - 2.4.9 / 5.5.42 - 5.6.16 / 5.4.37 - 5.5.11 / 9.4


Trouble is, will that not only work if there is only one article to fetch?

Say I have a category (or topic for old news) with 3 articles. I've translated one of these articles into French and all the rest have no language defined ('all').

So, if I look in English I'd want

Article 1 - All
Article 2 - All
Article 3 - All

In French I'd want

Article 1 - All
Article 2 - French (not the All version)
Article 3 - All

Would these changes do that?

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):


You could be right!

But if so that would mean no fix without a db change... Ie. some way to tie the translated articles together.

And if you were doing that, might as well go the whole hog and allow multiple languages at submit time. Meaning a series of sub-screens to input the other versions - called up in similar way to Forums adding Attachments.

Pro_News CM™ - Content Management for Dragonfly CMS™

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux / 1.3.39 - 2.4.9 / 5.5.42 - 5.6.16 / 5.4.37 - 5.5.11 / 9.4


Hello,

I also had to think about this in the past.
My conclusion, either you have to make copies of all articles to each language you want to support, or you find a way to have correct contents with the mix of "all" flagged articles and the localized ones. My experience is that both ways are not satisfying, even if the first option let's you get what you expect, but with a hudge amount of work for multiple language support, the second solution is not usable in real internationalized sites.

I asked my self if the best way is to have unique ID for a given article that remains the same in all tranlated versions.
I mean in DB the primary key should be a combination of the two fields ID and Language.
Doing this you can select the article to display from the available translations by using it's ID. If the requested language is available, display it, if not fall back to the default language version.

Please take this as athought of a hobby programmer. perhaps there a lot of reasons this can not work.

Movix

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux/Apache/MySQL 5.1.49/PHP 5.3.6/ DF 9.3.2.0


Oh, i just understood your last post Layingback, and this seems to be one reason it's a hudge work to do.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux/Apache/MySQL 5.1.49/PHP 5.3.6/ DF 9.3.2.0


is there a way to create a global localisation layer over the database layer ?
I mean to have a global language table that handle the IDs of various contents with their associated table names.
Upon a DB request the database layer modifies the SQL request to have the language flag integrated in the realy executed request.

For the small programming skills i have this seems to be a very hudge work and also would considerably increase DB requests, but perhaps there is some idea that can help

Movix

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux/Apache/MySQL 5.1.49/PHP 5.3.6/ DF 9.3.2.0

All times are UTC


Jump to: