Translating LISE item detail view

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
WDJames
Forum Members
Forum Members
Posts: 64
Joined: Tue Feb 13, 2018 1:09 pm

Translating LISE item detail view

Post by WDJames »

Hi All,

We have a bilingual website (MleCMS) which is using LISE to display resources which are bilingual via field definitions. The detail view of the LISE item is using a page which is outside of the bilingual languages hierarchy. In order to display the correct language on the LISE detail page, we are using session variables to set the current language on the summary page. The issue with this approach is that we are unable to translate the LISE item.

Is there a way that we can translate the detail page? I did think of loading all the content within the page and then use javascript to toggle between languages but this would make the html of the page twice as long. The other way I was going to try was to have a form on the detail page (that looks like the translate button) which changes the value of the session variable on click but I don't know where to start.

Any help will be greatly appreciated and apologies for the long post.

Thanks,

James
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3491
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: Translating LISE item detail view

Post by velden »

So, to summarize, you want a visitor who lands on the resource's detail page in language A to be able to browse to the same resource's detail page in language B?

I'm no SEO expert but I think it doesn't make sense to SE's when it finds different content (language) at the same url. Further you may need to take care of proper meta information about the language.

Perhaps you could use a custom .htaccess rewrite rule (or more) to take care of the detail page. Then also create custom urls in your summary template(s).

E.g. (untested):

Custom url in summary template
{root_url}/{$current_lang_code}/resources/alias-of-resource
(e.g. https://www.example.com/en/resources/my-resource)

Then a rewrite rule which 'translates'
en/resources/my-resource --> resources/my-resource?lang=en (fit to match the url of what lise would generate and append ?lang=en)

The visitors and SE's would see language specific urls and you can use $smarty.get.lang to determine the language.

Drawback is that you probably need to hardcode something in the .htaccess (part of the url) but will it ever change?

If you don't mind showing the part ?lang=en in the url to visitors and SE's it's much easier of course. Then you can just add it to the LISE generated urls and use it in your detail template.
WDJames
Forum Members
Forum Members
Posts: 64
Joined: Tue Feb 13, 2018 1:09 pm

Re: Translating LISE item detail view

Post by WDJames »

Hi Velden,

Thanks for the reply, to be honest I didn't think about the SEO implications. I ended up using the query string method but I had to use the a different variable because the {$lang} variable was being used by MleCMS. I added the query string (which gets the current page language via MleCMS) to the summary template:

<a href="{$item->url}?lang={$lang_parent}">item title</a>

Then I used {assign var="language" value=$smarty.get.lang} to display the correct content on the detail page.

Thanks again for pointing me to the right direction.

James
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3491
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: Translating LISE item detail view

Post by velden »

Another suggestion (thx DIGI3):

Why don't you use the detailpage parameter of LISE to let it generate urls to a language-specific detail page.

E.g. {LISEwhatever detailpage=resource-detail-$lang ...}

You could then keep the detail pages inside the Mle hierarchy.
WDJames
Forum Members
Forum Members
Posts: 64
Joined: Tue Feb 13, 2018 1:09 pm

Re: Translating LISE item detail view

Post by WDJames »

That is how I used to do it but for some reason the detailpage parameter isn't working on the version of LISE I am using. Also, when I used this method before, the detail page's ID is displayed on the URL (https://website.com/lise/item/25) which for me is "uglier" than having the query string. I'm trying to figure out how to use htaccess to redirect https://website.com/lise/item?lang=en to https://website.com/lise/item/en and then possibly capture the language to display the correct content.

Thanks again for all the help.
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3491
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: Translating LISE item detail view

Post by velden »

Don't redirect but rewrite.

.htaccess rewrite rule can translate your pretty url to the ugly one ending with ?lang=en while hiding that from the user.
WDJames
Forum Members
Forum Members
Posts: 64
Joined: Tue Feb 13, 2018 1:09 pm

Re: Translating LISE item detail view

Post by WDJames »

Hi Velden,

I see that you too are "burning the midnight oil".
Don't redirect but rewrite
Are you able to expand on this?

I think I've come up with the solution that works best for me. On the LISE summary I have:

<a href="{$item->url}-{$lang_parent}"> (https://website.com/resources/item-en)

and my htaccess is:

RewriteRule ^resources/(.*?)-([a-z]{2})$ /resources/$1?lang=$2 [QSA,L]

Which displays the https://website.com/resources/item-en url but server is queried for https://website.com/resources/item?lang=en

The only issue is that I have to add each LISE instance to the htaccess.
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3491
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: Translating LISE item detail view

Post by velden »

If those LISE details urls are the only urls ending in the two character language string then you can generalize the rule.

RewriteRule ^([^/]+)/(.*?)-((en|nl|fr|de))$ /$1/$2?lang=$3 [QSA,L]

Or come up with a detail url format you know will be unique.
WDJames
Forum Members
Forum Members
Posts: 64
Joined: Tue Feb 13, 2018 1:09 pm

Re: Translating LISE item detail view

Post by WDJames »

Hi Velden,

That's great. Thank you for all the help.

Thanks,

James
Post Reply

Return to “Modules/Add-Ons”