in progress Custom Module Multi Language

SoftDesigns
SoftDesigns
@softdesigns
7 years ago
242 posts
GOAL : On any of our Custom Modules: Add Dropdown or Toggle - Allow User to select between two languages
--
We understand the concept of resource language files.
Seems the code sample below is required to use language files in JR Smartly templates:
<span class="jraudio_title">{jrCore_lang module="jrAudio" id="14" default="audio file"}: </span> {$item.name}<br>
However most JR code we search only has one language file: en-US.php
--
We need sample code on how to "switch" between two JR language files?
updated by @softdesigns: 07/30/17 01:01:29PM
michael
@michael
7 years ago
7,714 posts
Add links to the page:
<a href="?set_user_language=es-ES">Spanish</a>
<a href="?set_user_language=en-US">English</a>
<a href="?set_user_language=fr-FR">French</a>

Docs: "Translate Jamroom into another Language"
https://www.jamroom.net/the-jamroom-network/documentation/jamroom-admin-handbook/541/translate-jamroom-into-another-language#adding-flags-to-change-the-language

--
Most jamroom modules only come with the en-US.php because we dont speak any other languages. Those language files get scanned into the database so they can be changed in the ACP. You can either add another language file to your module, or do it via the ACP, same thing.

Related docs:
https://www.jamroom.net/the-jamroom-network/documentation/module-developer-guide/789/module-file-system-structure
https://www.jamroom.net/the-jamroom-network/documentation/module-developer-guide/783/jrcore-lang
SoftDesigns
SoftDesigns
@softdesigns
7 years ago
242 posts
Great - We have tested adding a second language toggle via custom module template links - and seems working well.
--
JR Platform seems very well designed, already has everything in place for multi-language custom modules.
--
Will need more time for study and further testing..
--
Great Support :)
updated by @softdesigns: 04/28/17 06:27:17AM
SoftDesigns
SoftDesigns
@softdesigns
7 years ago
242 posts
After further testing - the language switch almost works, but notice two issues:
--
1 : On first time users hits module template, the custom module selects the wrong language by default: How to set which language file is the "default" for the custom module? (Not at the site or skin level, just at the custom module level)
--
2 : After user clicks a link to change the language - it works UNTIL they click off that page. So the custom module reverts back to the default language after they hit a different module template page, even though the user selected a different language...
--
Maybe we are missing some config code?
Please Advise...
updated by @softdesigns: 04/28/17 07:09:00PM
michael
@michael
7 years ago
7,714 posts
Languages are a USER level thing. Its expected that if you choose a language once, then that is the language you're going to want to see everywhere from then on.

I HATE HATE HATE google's method of "Oh, we see you're in japan, you must want everything in Japanese." Its sooooo annoying. personal annoyance that gets to me......

anyhow. When you change the language, you're changing it for the user. It should stay set until the user changes it again.

There is a way to set the default language for the site via the ACP
There is a way to set the default language for users in a quota. (i think)
If you need it different than that, i might need a setup to test against.

2. it does? I thought that would set the users choice of language in their DB settings. Might need to look into that.
michael
@michael
7 years ago
7,714 posts
My annoyance in screenshots (screenshot)
* my browser is in english
* the content of the discussion is all in english
* WHY would I want the surrounding context in a different language....... makes no sense.

Heaps of sites do it though.
google_lanugage.jpg
google_lanugage.jpg  •  209KB

SoftDesigns
SoftDesigns
@softdesigns
7 years ago
242 posts
@Michael: RE: Google Language – Yes – Totally Agree: After a decade living in Asia, I share your pain for the mess of Google Language auto detecting and setting language based on location - extremely annoying. Let us ensure to have our JR site multi-language user experience much better than Google – haha.
--
RE: JR Language files: Setting the language at the USER level is great idea – should work well for us.
--
#1: If user has never selected a language - Maybe need a META setting in custom module, to set default language? Whatever you think best...
--
#2: After further testing: Selected language still does not "stick": After user clicks a link to change the language - it works UNTIL they click off that page. Not sure if this is a bug, or if we are still missing something.
--
FYI: We have a STAGE site running JR live in Cloud IDE at www.C9.io (recently purchased by Amazon) : One click code change, save, and instantly run module changes - enabled for remote team coding :)
We can "share" our STAGE workspace where you can instantly run our test code, and quickly see this issue in real-time.
If JR staff has a www.C9.io account UserName please send in reply. ( C9 offers 1 free workspace )
If you do not have a C9 free account, we have an extra account – but will need to send private ticket - with our C9 login credentials.
updated by @softdesigns: 04/29/17 06:42:46PM
brian
@brian
7 years ago
10,148 posts
SoftDesigns:
#1: If user has never selected a language - Maybe need a META setting in custom module, to set default language? Whatever you think best...

If a user has never selected a language, they will use the value as set in ACP -> Users -> Global Config -> Account Settings (tab) -> Default Language.

SoftDesigns:
#2: After further testing: Selected language still does not "stick": After user clicks a link to change the language - it works UNTIL they click off that page. Not sure if this is a bug, or if we are still missing something.

Sounds like you are not actually changing the language - you may just be showing them the selector. When the user actually selects a new language, you must RELOAD the page with the "set_user_language" URL parameter added (like Michael outlined above). The language must be a language installed in your JR, and it will set a cookie called "jr_lang", so check that that is being set.

Let me know if that helps.


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
SoftDesigns
SoftDesigns
@softdesigns
7 years ago
242 posts
All our language file and URL settings seem correctly coded as Michael outlined above.
--
Maybe the issue related to this:
When we check cookies - actually we see 2 jr_lang cookies set differently: One for the User at Profle level, and one for the Custom Module?
--
Maybe because we added the "set_user_language" URL inside a Custom Module template?
--
Where should we add the "set_user_language" URL - at the module template level or site level ?
updated by @softdesigns: 04/30/17 04:23:25PM
michael
@michael
7 years ago
7,714 posts
I believe the issue you are seeing is because the user session is not synced. If you logout, then back in again, your changed chosen language should persist.

I have code in the next version of jrUser that will sync the user session when the user language is changed via the link method.

Tags