Jump to content

Bilingual Translation


Miguel Bambo

Recommended Posts

I want  if I select the English language Flag in the website the blog returns
Facebook like in English.

and if I select Portuguese Flag in the website, the blog  returns:
Facebook like Portuguese.

 

IN RESUME: I want bilingual Social plugin.

 

<script type="text/javascript">
                    (function(d, s, id) {
                      var js, fjs = d.getElementsByTagName(s)[0];
                      if (d.getElementById(id)) return;
                      js = d.createElement(s); js.id = id;
                      js.src = "//connect.facebook.net/pt_PT/all.js#xfbml=1";
                      fjs.parentNode.insertBefore(js, fjs);
                    }(document, 'script', 'facebook-jssdk'));
</script>

Also, I want it for DATE format in my blog posts (weekday and Month ) to be bilingual. For instance if English flag is selected then returns date format like
Saturday, February 21, 2016

and if Portuguese flat is selected then return
Sábado, 21 de Fevereiro de 2016.

So, how to adjust the javascript to set a language acording to the user selection through flag.

Regards.
 

Edited by miguelbambo (see edit history)
Link to comment
Share on other sites

I want something like this but I am not sure where to start.

 

<ul id="first-languages" class="countries_ul">
            {foreach from=$languages key=k item=language name="languages"}
                <li {if $language.iso_code == $lang_iso}class="selected_language"{/if}>
                {if $language.iso_code != $lang_iso}
                    {assign var=indice_lang value=$language.id_lang}
                    {if isset($lang_rewrite_urls.$indice_lang)}
                        <a href="{$lang_rewrite_urls.$indice_lang|escape:htmlall}" title="{$language.name|escape:'html':'UTF-8'}" rel="alternate" hreflang="{$language.iso_code|escape:'html':'UTF-8'}">
                    {else}
                        <a href="{$link->getLanguageLink($language.id_lang)|escape:htmlall}" title="{$language.name|escape:'html':'UTF-8'}" rel="alternate" hreflang="{$language.iso_code|escape:'html':'UTF-8'}">
     
                    {/if}
                {/if}
                        <img src="{$img_lang_dir}{$language.id_lang}.jpg" alt="{$language.iso_code|escape:'html':'UTF-8'}" width="16" height="11" />
                {if $language.iso_code != $lang_iso}
                    </a>
                {/if}
                </li>
            {/foreach}
            </ul>

Link to comment
Share on other sites

Hi,

 

I supose that you are trying to change it on the template file (.tpl), you should use the smarty template language.... try to use

<script type="text/javascript">
                    (function(d, s, id) {
                      var js, fjs = d.getElementsByTagName(s)[0];
                      if (d.getElementById(id)) return;
                      js = d.createElement(s); js.id = id;
{if isset($language_code) && $language_code=="en-us"} 
js.src = "//connect.facebook.net/en_us/all.js#xfbml=1";
{else}
js.src = "//connect.facebook.net/pt_PT/all.js#xfbml=1";
{/if}                     
                      fjs.parentNode.insertBefore(js, fjs);
                    }(document, 'script', 'facebook-jssdk'));
</script>
  • Like 1
Link to comment
Share on other sites

@Flávio's

Thank you for your prompt response.

Yes I want that I will try and I will let you know.

 

And what about the date in the same way?

Right now ive tried to change it but just was able to change into this format

Example: Saturday, 21 de February,2016.

 

I want to translate the weekday and the month into Portuguese and let it choose according to language flag selection as you did it above. Where to do it.

 

I just saw this part (file: _listing_blog.tpl)

 

{if $config->get('listing_show_created','1')}
        <span class="blog-created">
            <span class="icon-calendar"> {l s='On' mod='leoblog'}: </span>
            {strtotime($blog.date_add)|date_format:"%A, %e de %B, %Y"}
        </span>
        {/if}

 

Thanks.

Also I want ''if instruction'' above.

Edited by miguelbambo (see edit history)
Link to comment
Share on other sites

Yes, you will use in the same way

{if $config->get('listing_show_created','1')}
        <span class="blog-created">
            <span class="icon-calendar"> {l s='On' mod='leoblog'}: </span>            
{if isset($language_code) && $language_code=="en-us"}
{strtotime($blog.date_add)|date_format_locale:"%A, %e de %B, %Y":"us_EN"} 
{else}
{strtotime($blog.date_add)|date_format_locale:"%A, %e de %B, %Y":"pt_PT"} 
{/if} 
        </span>
{/if}

for more information....

http://www.smarty.net/docsv2/pt_BR/language.modifier.date.format.tpl

http://www.smarty.net/forums/viewtopic.php?t=18512&view=next&sid=b200241d77e8ce69d50478f5f93cdc1a

 

If it does not work, you will need create a variable on the controller file and pass to the tpl file....

http://doc.prestashop.com/display/PS15/Using+the+Context+Object

  • Like 1
Link to comment
Share on other sites

Maybe that was due to not find the field to translate those expressions.

I have translated on the source .tpl file not allowing me to put two options, english and portuguese words.This is applicable to the date.

If you know where to put english and portuguese returned words to facebook like and date (if I am correct) please, share it with me.

 

Regards.

Link to comment
Share on other sites

To translate the facebook block, try to use.... to me works fine.

    //console.log(jQuery('html')[0].lang+'test');
    var lang = jQuery('html')[0].lang;
    if(lang=='pt-pt')
    js.src = "//connect.facebook.net/pt_PT/all.js#xfbml=1&appId=334341610034299";
    else if(lang=='pt-br')
    js.src = "//connect.facebook.net/pt_BR/all.js#xfbml=1&appId=334341610034299";
    else
    js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=334341610034299";
    
	fjs.parentNode.insertBefore(js, fjs);

in your case would be

<script type="text/javascript">
                    (function(d, s, id) {
                      var js, fjs = d.getElementsByTagName(s)[0];
                      if (d.getElementById(id)) return;
                      js = d.createElement(s); js.id = id;

var lang = jQuery('html')[0].lang;
if(lang=='pt-pt') 
js.src = "//connect.facebook.net/pt_PT/all.js#xfbml=1";
else 
js.src = "//connect.facebook.net/en_us/all.js#xfbml=1";

                    
                      fjs.parentNode.insertBefore(js, fjs);
                    }(document, 'script', 'facebook-jssdk'));
</script>
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
×
×
  • Create New...