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

Can't have 2 different translations for the same phrase?
Oct 8, 2015 3:47 am by Johnie
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?
Re: Can't have 2 different translations for the same phrase?
Oct 8, 2015 4:40 am by Edvard
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!
Re: Can't have 2 different translations for the same phrase?
Oct 8, 2015 6:00 am by Johnie
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?
Re: Can't have 2 different translations for the same phrase?
Oct 10, 2015 11:16 pm by Edvard
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!
Re: Can't have 2 different translations for the same phrase?
Oct 25, 2015 11:29 pm by Johnie
Thanks for the help! I really appreciate it.
Re: Can't have 2 different translations for the same phrase?
Oct 26, 2015 5:56 am by Johnie
<?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.
Re: Can't have 2 different translations for the same phrase?
Oct 26, 2015 11:11 pm by Edvard
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!
Re: Can't have 2 different translations for the same phrase?
Nov 4, 2015 10:39 pm by Johnie
I'm using gtranslate folder in www root and gtranslate rules in .htaccess. # 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. <?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? <?php if ($_GET ['glang']=='it') { echo "Futuri genitori"; } else { echo "Future Parents"; } ?>
Re: Can't have 2 different translations for the same phrase?
Nov 5, 2015 9:47 pm by Johnie
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: # 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>
Re: Can't have 2 different translations for the same phrase?
Nov 6, 2015 8:08 pm by Johnie
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?
Re: Can't have 2 different translations for the same phrase?
Nov 8, 2015 3:43 am by Edvard
You need to wrap it with notranslate element as in my example.
Re: Can't have 2 different translations for the same phrase?
Nov 17, 2015 7:04 pm by Johnie
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? <?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
Re: Can't have 2 different translations for the same phrase?
Nov 18, 2015 2:55 pm by Edvard
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!

SIMILAR TOPICS

Export all custom translationsJul 5, 2018 11:50 amReplies: 1Post by: sadashiv
Limited custom translations?Feb 13, 2018 10:35 amReplies: 3Post by: natmatsci
Some of the translations on my site are not correctNov 13, 2017 9:33 amReplies: 5Post by: straightpoint
Translations lost and reverted to wrong version.Dec 6, 2016 4:07 pmReplies: 5Post by: sadashiv
[solved] edit translations problemDec 15, 2011 10:05 pmReplies: 19Post by: slweb2

Try GTranslate with a free 15 day trial