Suggestion to internationalization

Suggestion to internationalization

JFBConnect is great... I am more and more happy with it!

Now... a suggestion to help multi-language sites...

On system plugin "jfbcsystem" (jfbcsystem.php) you have on private function _getJavascript($appId, $fbLocale) (around line 50):

Code:

$locale = $lang->getDefault();

$locale = str_replace("-", "_", $locale);

This was causing all FB Javascript to work in en_GB (my Joomla default language, and NOT my Joomla current language)

So I took the liberty of.... errr... improving (not messing up, I hope) your code, and changed it to

Code:

$locale = $lang->getLocale();

$locale = str_replace("-", "_", $locale[2]);

Is this the right way to do it?
If so... will you consider including this change in future releases?
If not, could you correct me and include a solution in future realases?

Thanks!

fb_100000157901698
Alexandre
useravatar
Offline
76 Posts
Male 
Active Subscriptions:

None
Administrator has disabled public posting. Please login or register in order to proceed.

Re: Suggestion to internationalization

Alexandre,
I'm assuming you mean that it's not picking up the language set by the Joomla user? If so, I believe you're correct that we aren't doing it correctly (just getting the default of the site as a whole). I don't know immediately if your answer is the perfect solution, but if it works for you, great. I've added it to our tracker to investigate further for our next major release in July, and I can see this change (or something similar) being added then.

If I'm missing what you're saying, just let me know.

Thanks,
Alex

If you use our extensions, please consider leaving a rating and review at the Joomla! Extension Directory:
JFBConnect | SCLogin

alzander
Alex
useravatar
Offline
23813 Posts
Support Specialist
Administrator has disabled public posting. Please login or register in order to proceed.

Re: Suggestion to internationalization

Yep... that's it!

My site is on both English and Portuguese, and the user is able to choose his/hers language of preference. Your original code is always getting the default Joomla Language, not the currently selected language.

My main question is: is the only place I must change the code... or are there other parts of your code that deal with the language issue?

It's great news you are considering this for the next release!

fb_100000157901698
Alexandre
useravatar
Offline
76 Posts
Male 
Active Subscriptions:

None
Administrator has disabled public posting. Please login or register in order to proceed.

Re: Suggestion to internationalization

Alexandre,
Yes, that should be the only place. Everywhere else, we should be using Joomla to load the appropriate language file, and it will do it automatically based on the current user's language (falling back to the default if none is selected). The location you found is the only place that we load the Facebook Javascript library, which is what translates all of the Facebook widgets (Like, Comments, etc). There isn't anywhere else that should have this issue.

I'm assuming you're solution worked? If so, we'd love to know cause it will help us make sure we're implementing the right thing. It's already logged as an issue to be fixed in the next release, and I don't see any reason why we'd push it back.

Thanks again for you feedback,
Alex

If you use our extensions, please consider leaving a rating and review at the Joomla! Extension Directory:
JFBConnect | SCLogin

alzander
Alex
useravatar
Offline
23813 Posts
Support Specialist
Administrator has disabled public posting. Please login or register in order to proceed.

Re: Suggestion to internationalization

Alexandre,
I wanted to follow up on this post since we just implemented the solution to this problem for our upcoming release. It's a little different than your change, so wanted to call it out. Instead of using getLocale, we are using getTag. The locales returns an array of many different locales, like de_DE.UTF8, de_DE_CH.UTF8, etc. In order to use these values, you'd need to strip the .UTF8 part. Additionally, depending on the ordering of the locales, the best one might not be in the first spot of the array.

So, to fix for the upcoming release, we're doing the following, which only returns the most common locale for the language (de_DE, for example):

Code:

$locale = $lang->getTag();

$locale = str_replace("-", "_", $locale);

Feel free to try that solution and see if it works for you. We'd love to hear your feedback.

If you use our extensions, please consider leaving a rating and review at the Joomla! Extension Directory:
JFBConnect | SCLogin

alzander
Alex
useravatar
Offline
23813 Posts
Support Specialist
Administrator has disabled public posting. Please login or register in order to proceed.

Re: Suggestion to internationalization

So far so good... seems to be working fine and it is a much more elegant solution.

fb_100000157901698
Alexandre
useravatar
Offline
76 Posts
Male 
Active Subscriptions:

None
Administrator has disabled public posting. Please login or register in order to proceed.

Re: Suggestion to internationalization

Glad to hear it. We got another report from a user with a similar, but slightly different language issue, that it was working for them too. Additionally, they are using JoomFish, wish means it's compatible with that too.

So, for now, we're marking this as closed in our bug-tracker and, again, will be including in the next version as well.

Thanks for the feedback!

If you use our extensions, please consider leaving a rating and review at the Joomla! Extension Directory:
JFBConnect | SCLogin

alzander
Alex
useravatar
Offline
23813 Posts
Support Specialist
Administrator has disabled public posting. Please login or register in order to proceed.
There are 0 guests also viewing this topic
There are 0 users also viewing this topic

Board Info

Board Stats
 
Total Topics:
11498
Total Polls:
0
Total Posts:
48411
Posts today:
4
User Info
 
Total Users:
47473
Newest User:
martinpleon
Members Online:
1
Guests Online:
578

Online: 
cyberspyder
Social Stream
Refer and Earn

Like our extensions? You're not alone! That's why they're used on tens of thousands of websites. Now you can earn 20% of any sale you refer to SourceCoast.com.

We provide excellent documentation, well laid out sales pages and great support. All you need to do is spread the word and we'll take care of the rest.

Learn About Our Affiliate Program