Ogone has multilingual support so we could pass on the users language to the ogone payment interface. We need a helper function to map the language prefix onto the Ogone language codes.
// Languages supported by Ogone
$code = array(
'en' => 'en_US',
'fr' => 'fr_FR',
'nl' => 'nl_BE',
'it' => 'it_IT',
'de' => 'de_DE',
'es' => 'es_ES',
'no' => 'no_NO',
'tr' => 'tr_TR',
);
We'll look into it an see if we can make a working patch for it, we need this for a current project.
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | add-multilingual-support-1304676-10.patch | 4.86 KB | renzor |
| #11 | add-multilingual-support-1304676-11.patch | 4.87 KB | renzor |
| #8 | add-multilingual-support-1304676-8.patch | 3.35 KB | renzor |
| #7 | add-multilingual-support-1304676-7.patch | 3.33 KB | renzor |
| #5 | add-multilingual-support-1304676-5.patch | 4.79 KB | renzor |
Comments
Comment #1
mr.baileysIf you wish, you can also make use of the existing hook_commerce_ogone_data_alter()-hook, like so:
Comment #2
kristofvanroy commentedThanks for the feedback. We saw the alter hook, but if you hard code the mappings, there will be now way to let the store admin configure a new language. And in our case this will happen in a later phase of the project.
So a better approach is to configure the Ogone language code for every enabled drupal language. With fallback to a configurable default (eg. en_US) when no ogone language code is mapped to the current user language.
Comment #3
kristofvanroy commentedSmall update on this topic, only the following lang codes are currently supported by Ogone:
Default language used if no language value or if an invalid language value is sent:
en_US (English)
Other available languages are:
ar_AR (Arabic)
cs_CZ (Czech)
da_DK (Danish)
de_DE (German)
el_GR (Greek)
es_ES (Spanish)
fr_FR (French)
hu_HU hungarian)
it_IT (Italian)
ja_JP (Japanese)
nl_BE (Flemish)
nl_NL (Dutch)
no_NO (Norwegian)
pl_PL (Polish)
pt_PT (Portugese)
ru_RU (Russian)
se_SE (Swedish)
sk_SK (Slovak)
tr_TR (Turkish)
zh_CN (Simplified Chinese)
Comment #4
mr.baileysI wonder if we should not just ditch the current language setting and automatically map the Drupal site language with Ogone's languages (only problem would be nl, which I guess should be mapped to 'nl-NL'). I assume that's the behavior the majority of users would expect, no? (And the other < 5% of users can resort to the _alter hook).
Or do you have a use-case where you would want to deviate from such a default language mapping and allow the store administrator to specify which language Ogone should use for each Drupal language?
Another option would be to give the admin a couple of options:
(Where the latter option seems to be the one you need?).
Comment #5
renzor commentedWe've made a patch which will add a dropdown box per enabled language. Now you are able to assign language codes to any language that is enabled on your Drupal installation or to a default.
Comment #6
mr.baileysThanks, I'll try and take a moment to review later today. Some quick comments:
Comment #7
renzor commentedThe notices should be fixed in this updated version of the patch. Thanks for your comment.
Comment #8
renzor commentedKristof found a small bug in my previous patch, which is fixed in this one.
Thanks.
Comment #9
mr.baileysThanks for working on a patch for this!
I'm still not convinced that we should actually provide drop-downs for every enabled language, especially since most of the mappings will be no-brainers like 'Italian => Italian', 'German => 'German', 'Turkish => Turkish', etc, something we can do automatically without the need to provide a wall of drop-downs to end-users. However, I'm leaving it to svendecabooter to decide how to proceed.
If we do offer the drop-downs, I think we should:
a) Introduce vertical tabs and move language settings to a "Language" tab, and account settings to an "Account" tab.
b) Let the end-user choose between "Use language abc" (so basically no mapping) or "Manually map languages" (which is what this patch provides -- more of an expert option).
Now, on to a review of the patch itself:
The global $language variable is not used further down in the code, and is actually overwritten in a foreach causing the language on the payment settings form to be changed.
The first assignment is obsolete and should be removed.
I think we should use the user-friendly language names rather that ISO-codes in the drop-down (so for example: 'it_IT' => t('Italian'))
No need to assign an empty array.
Since language_list() always returns an array, I don't think we need to explicitly cast it here.
Ideally this should follow the Drupal coding standards for function comments
- One-line summary should be third-person and end with a period.
- Should include a @param and @return block.
It would also be great if we can somehow provide sensible defaults per language (since right now all language drop-downs are set to ar_AR).
Comment #10
renzor commentedThanks for reviewing the patch!I've cleaned up the patch, replaced the ISO codes of the drop-down fields with human readable names and added better support for defaults per language.About the drop-down boxes, I see your point that some of them are unnecessary. Although, I personally think it's best to leave them in. You never know if someone needs to change those mappings :). But I'm going to leave that up to you and Sven.Comment #11
renzor commentedThanks for reviewing the patch!
I forgot to sort the language codes alphabetically. So this patch includes a sorted code list :).
I've cleaned up the patch, replaced the ISO codes of the drop-down fields with human readable names and added better support for defaults per language.
About the drop-down boxes, I see your point that some of them are unnecessary. Although, I personally think it's best to leave them in. You never know if someone needs to change those mappings :). But I'm going to leave that up to you and Sven.
Comment #12
svendecabooterCommitted patch in #11 by renzor.
Added extra logic to generate the default prefix code: now there is verification if the default generated code based on the path prefix (e.g. 'fr' > 'fr_FR' actually exists as an Ogone language code. If not, it falls back to the default language / English (whatever is set).
This avoids a problem for language code 'en' where the code would attempt to set it to en_EN, which doesn't exist. The consequence of that is that English was set to Arabic by default instead...
Vertical tabs would be a good idea, but couldn't get them to work immediately...