heldercervantes

Some translations not showing

Recommended Posts

I've had this happen before, but now I got this problem again and I'm wondering what it's about.

I use the basic <?= __('Contacte-nos') ?> method for adding translatable text to templates. Some of these are not appearing on the form when I edit the file's translations in PW.

Take this line of code:

<?= __('1 ou +7 pessoas?') ?> <a href="#" class="contactsMenu"><?= __('Contacte-nos') ?></a>

The first string "1 ou +7 pessoas?" appears when I edit the translations, but the second one doesn't. Eventually I figured out I can only have one of these per line of code. Adding a line break somewhere somewhere between them was enough to make both translations show up in the form.

Problem solved, but curiosity remains. What is the reason for this?

Share this post


Link to post
Share on other sites

The reason for this is explained in the "code internationlisation" docs page. Small hint: It's because of the parser and the ability to have comments for translation on the same line.

  • Like 2

Share this post


Link to post
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


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By K4mil
      Hello
      I've recently run into a trouble with translatable strings in my template files. Shortly speaking translatable strings show up properly in language panel, I can create and save translations, everything looks just fine in backend. The problem is that the only outputed value is the hardcoded one. It's definitely not a problem with template code itself because this happened even on simple test template with a  translatable string alone. 
      There are no errors, I don't see anything special in logs. I just recently moved site from my local server to my ftp. There were some issues with paths in language files, but I have fixed it. It's the newest dev version of PW. I really don't have idea where to look, I'm fighting with this second day, and slowly loosing my nerves.
    • By zaib
      I'm fetching results from a template which works fine but when i change the language (in my case changed language is ARABIC), its showing me nothing
      $getResult = $pages->find("template=t3Cities_list, tags={$page->title}"); where "tags" are checkboxes with multi selection, How i can match the values?
    • By Marcel Stäheli
      Hello
      if have a few article pages that have a multi-page reference field with tags about the content of the article. All tags of a given page are displayed and link to a tag-overview page.
      Every link has a query string added with the tag name like &tag=cars so that I know which articles have to be displayed on the tag-overview page,
      The tag name is created using $tag->name. Since the website is multi language using German (default) and English, I use $page->localName($language) to get the localized page name . The code looks like this:
      foreach($tags as $tag) { $tagsMarkup .= "<a href='" . wire('pages')->get('/tags-overview/')->url . "?tag=" . $tag->localName(wire('user')->language) . "'>" . $tag->title . "</a>, "; }
      The code works mostly fine, but when a page has the same name in both languages, the query string will have no value just ?tag=. Why?
       
      A second problem that might be tied to the first:
      Once on that tags-overview page, I check if the tag actually exists using:
       
      $allTags = $pages->get("/tags/")->children); if($allTags->has("name=$tag") {...} But as I read on the forum (https://processwire.com/talk/topic/2979-multi-language-page-names-urls/?page=6) that only checks for name in the default language. It was suggested to use $page->parent->path . "pageNameEnglish" but I'm not sure where and how to use it in my case.
      Any help?
       
    • By Nukro
      Hi Guys
      I have a problem with the Code Internationalization (Site Translation Files) in Processwire. I am using the method Ryan is describing in this topic and also the normal way of translating files. The weird behaviors are that translations are just gone after a change in the main translation file called _strings (uses Ryan method). Or some other weird behavior was, that the english translation of the _strings file were somehow ported inside the german _strings file. I really don't know what could cause this. Have ever witnessed something like that? 
      I have made some thoughts about this whole Code Internalization thing in ProcessWire and I am thinking to go another way (don't get me wrong, it's perfect for small to mid projects but in my opinion it is just a overkill for big projects), because at the beginning the strings we needed to translate were splitted up in many files which produced many site translation files to translate per language. It was just to much and confusing for the customer (and also for me), so that we needed another approach. So I tried Ryans method with one central translation files. The problem with this one is that it also gets confusing since it is a very big amount of strings to translate and also the problems described above. So for know I will try to make approach to store the strings in Pages. All translations of a string would be stored side by side. I know that this is probably more complex behind the scenes but it is far easier for the customer (especially with ListerPro). And I also like the idea of having the translations inside the DB instead in form of Files.
      What are your thoughts about it? Have ever done something like that?
      Greetings
      Orkun
    • By Fuad Ibrahimov
      Hi all!
      I have a problem with selecting default language in frontend.
      I tried to set default language from admin panel in Access->Users for guests and admin to another language, but it changed only backend language.
      I read a lot of topics about this problem and i didn't find any normal solution.