Jump to content

Recommended Posts

Posted

Hi guys, is there a way to translate hardcoded html text for example:

 

<div class="tabs">
<a href="#">Tab name in some language</a>
<a href="#">Tab name in some language2</a>
<a href="#">Tab name in some language3</a>
</div>

i know that we can do something like

<?php

if ($lang == 'en') {
echo "<a href="#">Tab name in English languge</a>"
}
if ($lang == "other ") {
echo "<a href="#">Tab name in other languge</a>"
}

I was thinking about module of some kind working like "Process Language Translator" or

in code u use variable tags like : {lang-TabNameInSomeLanguage}

<div class="tabs">
<a href="#">{lang-TabNameOne}</a>
<a href="#">{lang-TabNameTwo}</a>
<a href="#">{lang-TabNameThree}</a>
</div>

in Admin some sort of table like this with translation for each language we create.

Varialbe                              ENG                       DEU                                POL

TabNameThree         this is tab one            dies ist einer Tab           To jest jedna zakladka

Or there is totaly other easy way that im not aware of ?

Cheers

Paul.

Posted

There is no reason that you have to have any hard coded text at all really - if you are creating tabs, for instance, you can have the tab headers as fields, either generated by the page that is supplying the pane content or, if you are using them more globally, from some sort of global settings page. Then you can use multi-language fields quite happily.

  • Like 1
Posted

I think vxda is asking about the built-in gettext-like translatable strings in template files

Exacly !

thank you :)

Posted

One thing is not working for me dunno why, in API docs i see this should work:

$out = __("It's time for you \nto get to the party.");  // good 

but it seams not, here is my code:

<h2><?php echo __('Safe \nplastic surgery') ?></h2>

Any tips ?

Posted

You need double quotes "".

Also I guess the new line is visible when translating the string in the Pw admin.

To get a new line in html, you need the br tag:

<h2><?php echo nl2br(__("first line\nsecond line"));?></h2>
  • Like 2
  • 1 month later...
Posted
<h2><?php echo __('Safe \nplastic surgery') ?></h2>

Cannot reproduce this. Example works in Language Translator/ Language Translator Plus

You can use both (Single and Double quotes) look here: wire/modules/LanguageSupport/LanguageParser.php  function parseFile($file)

It doesn't work, if you have more than one translatable string in one line ,like

<h2><?php echo __('Safe \nplastic surgery') ?></h2><p><?php echo __('2nd string') ?></p>

The second string will not appear in the language translator. Its a bug. Maybe Ryan could help.

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.
×
×
  • Create New...