Can't have 2 different translations for the same phrase?

Popular automatic website translation tool

Can't have 2 different translations for the same phrase?

Postby Johnie » Thu Oct 08, 2015 7:47 am

Pro version - I have a client that I'm adding some custom Italian translations for on her site. When I made the changes a few of them kept changing. After looking over all the "human" edit files for the changes I realized that there was only one translation file for a couple of 2-word phrases that required different translations and when I change one it changes both. Presumably, the different translations for the same 2-word phrases are based on how they're used.

Is there a way to force a second translation file (for the same phrase) to be created for the page? One for each of the two different translations for the same 2-word phrase? Also: the contents of the translation file do not appear to be page specific either so unless they're defined by the translation file name, I need to find out if each translation I do changes every instance of whatever is translated site wide. If so, besides creating a second translation on a page, can I make other translations page specific if I need to?
Johnie
 
Posts: 13
Joined: Wed Jan 14, 2015 11:44 pm

Re: Can't have 2 different translations for the same phrase?

Postby Edvard » Thu Oct 08, 2015 8:40 am

Hi,

You will need to program it yourself.

You can detect the current selected language and show your own translation with class="notranslate" attribute on your site.

Thanks!
Regards,

Edvard Ananyan - GTranslate Team

Please leave your feedback on your CMS plugin directory. It is very important for us!
Google Translate Joomla
Google Translate WordPress
Google Translate Drupal
Edvard
Site Admin
 
Posts: 4185
Joined: Mon Jun 28, 2010 1:54 pm
Location: Yerevan, Armenia

Re: Can't have 2 different translations for the same phrase?

Postby Johnie » Thu Oct 08, 2015 10:00 am

I did a search for "notranslate" but did not find any examples of what to do when you need 2 different translations for the same phrase. I didn't even see the same question asked. Can you point me to an example that shows how to create a second translation for the same phrase please?
Johnie
 
Posts: 13
Joined: Wed Jan 14, 2015 11:44 pm

Re: Can't have 2 different translations for the same phrase?

Postby Edvard » Sun Oct 11, 2015 3:16 am

OK. Here is an example:

You have this phrase: Hello world. on 2 pages page 1 and page 2. You want to translate it into Russian, but on page 1 you want it to be translated to (ru)Hello world! on page 2 you want it to be translated to (ru)Hello World!!!

To have that, on your page 1 you need to write this code.

<?php if($lang == 'ru') echo '<span class="notranslate">(ru)Hello world!</span>'; ?>

on page 2 you need to have this:

<?php if($lang == 'ru') echo '<span class="notranslate">(ru)Hello World!!!</span>'; ?>

(ru) represents text in Russian and is just for example purposes.

Thanks!
Regards,

Edvard Ananyan - GTranslate Team

Please leave your feedback on your CMS plugin directory. It is very important for us!
Google Translate Joomla
Google Translate WordPress
Google Translate Drupal
Edvard
Site Admin
 
Posts: 4185
Joined: Mon Jun 28, 2010 1:54 pm
Location: Yerevan, Armenia

Re: Can't have 2 different translations for the same phrase?

Postby Johnie » Mon Oct 26, 2015 3:29 am

Thanks for the help! I really appreciate it.
Johnie
 
Posts: 13
Joined: Wed Jan 14, 2015 11:44 pm

Re: Can't have 2 different translations for the same phrase?

Postby Johnie » Mon Oct 26, 2015 9:56 am

Code: Select all
<?php
$session = JFactory::getSession();
$lang = $session->get('glang');
  if ($lang == 'it') { echo "Futuri genitori";
} else {
  echo "Future Parents"; }
?>


The site's in multiple languages so I couldn't figure out how to make your suggestion work and still include the default language so I went a different route but I'm not picking up the variable or possibly the condition if "it" is not correct for Italian? It's on the latest Joomla version using Sourcerer.
Johnie
 
Posts: 13
Joined: Wed Jan 14, 2015 11:44 pm

Re: Can't have 2 different translations for the same phrase?

Postby Edvard » Tue Oct 27, 2015 3:11 am

You forgot about <span class="notranslate">. Also are you using the GTranslate Pro plugin in Joomla or you have /gtranslate folder in your www root and you have gtranslate rulis in your .htaccess?

Thanks!
Regards,

Edvard Ananyan - GTranslate Team

Please leave your feedback on your CMS plugin directory. It is very important for us!
Google Translate Joomla
Google Translate WordPress
Google Translate Drupal
Edvard
Site Admin
 
Posts: 4185
Joined: Mon Jun 28, 2010 1:54 pm
Location: Yerevan, Armenia

Re: Can't have 2 different translations for the same phrase?

Postby Johnie » Thu Nov 05, 2015 2:39 am

I'm using gtranslate folder in www root and gtranslate rules in .htaccess.
Code: Select all
# gtranslate config
RewriteRule ^([a-z]{2}|zh-CN|zh-TW)/([a-z]{2}|zh-CN|zh-TW)/(.*)$ /$1/$3 [R=301,L]
RewriteRule ^([a-z]{2}|zh-CN|zh-TW)/([a-z]{2}|zh-CN|zh-TW)$ /$1/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-z]{2}|zh-CN|zh-TW)/(.*)$ /gtranslate/translate.php?lang=$1&url=$2 [L,QSA]
RewriteRule ^([a-z]{2}|zh-CN|zh-TW)$ /gtranslate/translate.php?lang=$1 [L,QSA]

#RewriteCond %{REQUEST_URI} ^/sitemap.xml
#RewriteRule .* /index.php?option=com_xmap&id=1&view=xml


I don't recall why I chose this method over the plugin but the plugin was never installed.

I don't think "notranslate" is applicable. Here's my situation and the simple solution I'm trying to use:
I have a 2 word title used twice on the same page but the client wants them to have different Italian translations. They are identical so they are both using the same translation file for the 2 word title. Although I can't find the "notranslate" class rules defined anywhere, I don't think it's applicable because I need them both to be translated for every language except Italian.

Here's what I'm trying to do where the same title is used twice on the same page - "same phrase" and "same phrase". The first one I want gtranslate to handle as usual for all languages. The second one I want gtranslate to handle as usual for all except for the Italian translation which I'll supply like this --> if language is 'it" echo "different translation" else echo "same phrase" so that if it's not Italian, the "same phrase" will be translated as usual for whatever language is chosen.

Sounds simple and it should be but I can't get the language code. Thanks to your most recent reply I now realize I was using the wrong variable (plugin variable) but the other one doesn't work either so it's frustrating.

While in Italian GTranslate page, the following code returns "no". If I blank the 'it' field it returns "yes" which tells me it is not returning any language code whatsoever.
Code: Select all
<?php if ($_GET ['glang']=='it'){ echo "yes"; } else { echo "no"; } ?>


The site is http://www.familytreesurrogacy.com and the 2 "Future Parents" titles on the homepage are the ones that need different translations (for Italian only). The 2nd instance (middle, left) is the one I'm trying to change.

Since $_GET ['glang'] does not work (below), is there another way to get the language code?
Code: Select all
<?php         
  if ($_GET ['glang']=='it') {
  echo "Futuri genitori";
  } else {
  echo "Future Parents"; }
?>
Johnie
 
Posts: 13
Joined: Wed Jan 14, 2015 11:44 pm

Re: Can't have 2 different translations for the same phrase?

Postby Johnie » Fri Nov 06, 2015 1:47 am

SOLVED - For anyone that needs the language file code... just add &glang=$1 to the 2 lines of the gtranslate config portion of your .htaccess file shown below and you can then use $_GET ['glang'].

Change the last 2 lines of the gtranslate config portion of the .htaccess file below from this:
Code: Select all
# gtranslate config
RewriteRule ^([a-z]{2}|zh-CN|zh-TW)/([a-z]{2}|zh-CN|zh-TW)/(.*)$ /$1/$3 [R=301,L]
RewriteRule ^([a-z]{2}|zh-CN|zh-TW)/([a-z]{2}|zh-CN|zh-TW)$ /$1/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-z]{2}|zh-CN|zh-TW)/(.*)$ /gtranslate/translate.php?lang=$1&url=$2 [L,QSA]
RewriteRule ^([a-z]{2}|zh-CN|zh-TW)$ /gtranslate/translate.php?lang=$1 [L,QSA]


To this by adding "&glang=$1" (no quotes) to both of the last 2 lines:
___________________________________________________________________________________________
# gtranslate config
RewriteRule ^([a-z]{2}|zh-CN|zh-TW)/([a-z]{2}|zh-CN|zh-TW)/(.*)$ /$1/$3 [R=301,L]
RewriteRule ^([a-z]{2}|zh-CN|zh-TW)/([a-z]{2}|zh-CN|zh-TW)$ /$1/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-z]{2}|zh-CN|zh-TW)/(.*)$ /gtranslate/translate.php?lang=$1&url=$2&glang=$1 [L,QSA]
RewriteRule ^([a-z]{2}|zh-CN|zh-TW)$ /gtranslate/translate.php?lang=$1&glang=$1 [L,QSA]
___________________________________________________________________________________________

In my case I needed it to change the definition for a 2nd instance of the same phrase. In Joomla, using the Sourcerer plugin (allows you to use php in articles by wrapping php with {source} tag), once I changed the .htaccess file I was able to assign the new Italian translation.

<h3 class="hidit"><strong>
{source}
<?php
if ($_GET ['glang']=='it') {
echo "Futuri genitori";
} else {
echo "Future Parents"; }
?>
{/source}
</strong></h3>
Johnie
 
Posts: 13
Joined: Wed Jan 14, 2015 11:44 pm

Re: Can't have 2 different translations for the same phrase?

Postby Johnie » Sat Nov 07, 2015 12:08 am

NOT SOLVED afterall !!!

After the article with the php code to replace the 2nd instance of the same phrase with a different name (from post above) was published, it worked perfectly once I was able to get the language code, as it should. BUT, when I switched to English and then back to Italian again, it somehow bypasses the php code and goes back to the original md5/definition.

If I re-publish the article it works again but it reverts back when the language is switched. In fact, I just checked it again and it only works if I am in Italian language when I re-publish articles. If I'm in the native language (English) and I re-publish it, and then switch to Italian, the php code/2nd definition are completely ignored.

Does anyone no how to resolve this?
Johnie
 
Posts: 13
Joined: Wed Jan 14, 2015 11:44 pm

Re: Can't have 2 different translations for the same phrase?

Postby Edvard » Sun Nov 08, 2015 7:43 am

You need to wrap it with notranslate element as in my example.
Regards,

Edvard Ananyan - GTranslate Team

Please leave your feedback on your CMS plugin directory. It is very important for us!
Google Translate Joomla
Google Translate WordPress
Google Translate Drupal
Edvard
Site Admin
 
Posts: 4185
Joined: Mon Jun 28, 2010 1:54 pm
Location: Yerevan, Armenia

Re: Can't have 2 different translations for the same phrase?

Postby Johnie » Tue Nov 17, 2015 11:04 pm

Sorry for being so dense but I'm still not understanding the "notranslate" class. Specifically, I only want it to apply for the Italian translation. I've tried using the "notranslate" class every way I could think of but... trial and error is a huge time suck. But it's what I'm stuck with since I can't find where it's defined. Is the code below what you're saying? If not, can I just pay you to do it?

Code: Select all
<?php         
  if ($_GET ['glang']=='it') {
  echo " <span class="notranslate">Futuri genitori</span>";
  } else {
  echo "Future Parents"; }
?> - See more at: http://gtranslate.net/forum/can-have-different-translations-for-the-same-phrase-t4372.html#p19355
Johnie
 
Posts: 13
Joined: Wed Jan 14, 2015 11:44 pm

Re: Can't have 2 different translations for the same phrase?

Postby Edvard » Wed Nov 18, 2015 6:55 pm

Hi,

Yes it is correct code. In Italian version you will have "Futuri genitori" on other languages you will have translation of "Future Parents" to the current language.

Make sure that $_GET['glang'] is defined. You may try to do this to see the content of it.

<?php echo $_GET['glang']; ?>

Thanks!
Regards,

Edvard Ananyan - GTranslate Team

Please leave your feedback on your CMS plugin directory. It is very important for us!
Google Translate Joomla
Google Translate WordPress
Google Translate Drupal
Edvard
Site Admin
 
Posts: 4185
Joined: Mon Jun 28, 2010 1:54 pm
Location: Yerevan, Armenia


  • Related Topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 0 guests

2GLux
cron