Jump to content

Translation strategy : one field per whole menu or per link ?


Doc
 Share

Recommended Posts

Hi,

I have a menu at the top of my homepage (~15 links). I'd like to translate it.

Example :

<a href="#" class="menu-item">collection</a>
<a href="#" class="menu-item">products</a>
<a href="#" class="menu-item">support</a>

[...]

What's your prefered method to translate that ? I already have my configuration ready for different languages according to the url : /en -> display english, /fr -> french, ...

Do you add one more field per link on the homepage or do you add a single "menu" field ?

With one field / link you add content by filling your textlanguage with : "collection" for example and then display it on the homepage through $page->link1

With one field / menu you add the whole html stuff I guess, with the CKEditor for example on a textarealanguage field :

<a href="#" class="menu-item">collection</a>
<a href="#" class="menu-item">products</a>
<a href="#" class="menu-item">support</a>

and then display it on the homepage the same way than with one field / link.

Which method would you use ?

Let's vote :)

Thanks

Link to comment
Share on other sites

I've already read that one what makes me think I wasn't clear enough (or maybe I've myself misunderstood the documentation you pointed out)

Actually I want to translate my menu, but not automatically through a translation function, I prefer to do that myself.

Until now I'm using the multi-language-url functionnalities, I'm adding fields and translate them in the admin, and I'm happy with that, it works.

I'm using it for large part of text, such as a feature description, and so on.

The menu is composed of ~15 links and I don't know if I have to go with 15 fields more on the homepage or only one with html code inside.

Link to comment
Share on other sites

One more question I ask myself :

I've just made a test and it works (echo __("..."))

So, when do you choose to use that way of translating stuff vs use a textarealanguage field for example ?

I guess if it's a huge description -> go for the field, and if it's tiny (a sentence or two) -> go for the translatable string ?

Link to comment
Share on other sites

Everything that's static text as part of your theme/template/page-layout should be put in code and be (optionally) translated. Everything which is content (a.k.a. the dynamically filled in data) is part of some page and therefore using multi language fields. Your example of a navigation is in my opinion the gray area in between. It can be static enough to be hardcoded, but it can be as dynamic as to use multi language page titles or alike.

Link to comment
Share on other sites

5 hours ago, Doc said:

Example :

<a href="#" class="menu-item">collection</a>
<a href="#" class="menu-item">products</a>
<a href="#" class="menu-item">support</a>

Based on the fact that you do not have URLs in the link hrefs I guess this menu is for navigating to blocks of content within a single page.

Rather than hardcode this menu into the template and translate it using __() you could consider using a Repeater / Repeater Matrix for your content blocks and add a title field to your repeater items. Then you can create translations for the titles in Page Edit and generate your menu dynamically. Seems like it would be easier to maintain that way.

  • Like 1
Link to comment
Share on other sites

Thanks to both of you.

@Robin S, I don't have URL in the links now but there will be soon :) I've just pasted the code before filling them. That menu is not designed to navigate within a single page but through the whole website.

Link to comment
Share on other sites

1 hour ago, Doc said:

That menu is not designed to navigate within a single page but through the whole website.

Although you can insert a static menu into your template, usually a CMS-powered website would use a menu that is generated dynamically according to the pages in the website. The text in the menu would be sourced from the titles of the pages.

To create translations of page titles you can install the language support modules.

2017-01-22_222045.png

I suggest you read the language support documentation, and the section about multi-language fields in particular.

Link to comment
Share on other sites

Thanks Robin S,

I'm reading/testing stuff from the documentation right now.

The menu is dynamic (the url changes according to the language setting, so does the text in the menu).

I'm actually trying to find a solution to my first problem : https://processwire.com/talk/topic/15330-how-to-load-the-right-language/#comment-137135 

I'm not still satisfied with my way to handle it.

Lostkobrakai gave me translatable strings and now I'm trying to dynamically load them in the right language whatever the url (it works when I switch '/' to '/en').

I'd like to "force" the english translation without '/en' url...

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...