Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
Locked
0

How to create a dynamic multilingual website with web apps and liquid

Contributor ,
Jul 02, 2016 Jul 02, 2016

In the thread Re: Liquid: What are the suggested best practises for multiple languages? only a part of my problem is solved.

I've created a listing web app which contains several data source fields.

These data source fields have multiple values where the client has to choose the applicable (one) value. I.e location: waterfront , rural area, etc. etc.

These values have to be translated from English to Dutch.

So, how do I have to construct my webpage with liquid markup based on the client's input c.q. output?

Thanks for any help.

Kind regards,

Carla

TOPICS
Developer
977
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , Sep 14, 2016 Sep 14, 2016

Hi Carla,

You have many options available to you with liquid, so with the datasource_id  from the original web app, you can call up another webapp referencing that ID to get the information you want, and collect the data in a collection or display in a custom template (.tpl) file.

Here's an example. Inside your detail.html web app template

Using a collection:

{module_webapps id="3rdPartyWebApp" filter="item" itemId="{{ dataSourceID }}" collection="webAppData" template=""}
{{ webAppData.items[0].descr

...
Translate
Guide ,
Jul 10, 2016 Jul 10, 2016

I've done a few multi-language sites it all depends on what you are trying to do. Because words in one language might be 2 characters and the equal word in the other 10 you need to factor in the design of the site. Unless you are only wanting to translate a little bit of the site (and not the header and footers etc) I would suggest having two templates. It's more work obviously but it's better for the client and the user as both sites can be tweaked to fit the language perfectly.

I understand this is might not what you want to hear but I hope it helps.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jul 12, 2016 Jul 12, 2016

Thanks for your reply. But the "problem" lies in the web-apps with field type "datasource". These are in English and the stored data in those fields (which are emulated in the back-end as a list-type-field) have to be translated when "called" with liquid.

Do you have a solution for that?

Thanks.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Sep 14, 2016 Sep 14, 2016

When you use another web-app as input for a datasource field you can only retrieve the Item Name value of the web app-item. I would like to display the Item Description al well. In the BC-doc's I can only find examples of displaying  Item Description when rendering the web-app on a page.

How can I make it possible to retrieve the Item Description of the datasource web app-item?

Thanks,

Carla

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Sep 14, 2016 Sep 14, 2016

Hi Carla,

You have many options available to you with liquid, so with the datasource_id  from the original web app, you can call up another webapp referencing that ID to get the information you want, and collect the data in a collection or display in a custom template (.tpl) file.

Here's an example. Inside your detail.html web app template

Using a collection:

{module_webapps id="3rdPartyWebApp" filter="item" itemId="{{ dataSourceID }}" collection="webAppData" template=""}
{{ webAppData.items[0].description }}

Using a template:
{module_webapps id="3rdPartyWebApp" filter="item" itemId="{{ dataSourceID }}" template="display_webapp_description.tpl"}

... content of display_webapp_description.tpl:

{{ description }}

You should be good to go.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Sep 14, 2016 Sep 14, 2016

Hi Stephen,

Thank you so much for your reply. I will try your solution and let you know if it works in my case.

Regards, Carla

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Sep 14, 2016 Sep 14, 2016

Hi Stephen,

Your solution just works fine.   Luckily the datasource id and the item-id are the same.

So you can use an "assign" to store the ID {% assign dataSourceID = {{ this.retrieveValue1_id | strip_html }} %}  itemId="{{ dataSourceID }}" or just put in the tag itemId="{{this.retrieveValue1_id }}"

Regards, Carla

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Sep 14, 2016 Sep 14, 2016

Hi Carla,

To be more precise and accurate, when assigning a variable in this context.

{% assign dataSourceID = retrieveValue1_id %}

you don't need {{ }} inside a {% %} and you don't need "this." necessarily... but yeah, you have the idea spot on with your examples.

Thanks

Stephen

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Sep 15, 2016 Sep 15, 2016
LATEST

Hi Stephen,

Yes, you're absolutely right. A little advice: never post code when it's getting late.

Thanks, Carla

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines