<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>NemoPS &#187; language</title>
	<atom:link href="https://nemops.com/tag/language/feed/" rel="self" type="application/rss+xml" />
	<link>https://nemops.com</link>
	<description>Prestashop Tutorials, Modules and More!</description>
	<lastBuildDate>Wed, 05 Dec 2018 13:25:23 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.1.35</generator>
	<item>
		<title>Creating Multilanguage attachments in PrestaShop 1.7</title>
		<link>https://nemops.com/prestashop-1-7-multilanguage-attachments/</link>
		<comments>https://nemops.com/prestashop-1-7-multilanguage-attachments/#comments</comments>
		<pubDate>Wed, 05 Dec 2018 13:24:30 +0000</pubDate>
		<dc:creator><![CDATA[Nemo]]></dc:creator>
				<category><![CDATA[Tips n Tricks]]></category>
		<category><![CDATA[attachments]]></category>
		<category><![CDATA[language]]></category>
		<category><![CDATA[prestashop 1.7]]></category>

		<guid isPermaLink="false">http://nemops.com/?p=3173</guid>
		<description><![CDATA[<p>Attachments are a great way to provide your customers with rich pre-sale information about your products. But what if your site is multilingual? Let’s see how to make Attachments multilanguage in PrestaShop 1.7. Watch the screencast Text Version Step 1 – Adding the attachments Adding attachments with the proper name is fundamental for this technique. [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://nemops.com/prestashop-1-7-multilanguage-attachments/">Creating Multilanguage attachments in PrestaShop 1.7</a> appeared first on <a rel="nofollow" href="https://nemops.com">NemoPS</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>Attachments are a great way to provide your customers with rich pre-sale information about your products. But what if your site is multilingual? Let’s see how to make Attachments multilanguage in PrestaShop 1.7.</p>
<p><span id="more-3173"></span></p>
<h2>Watch the screencast</h2>

	<div class="video-embed">
		<iframe width="640" height="360" src="http://www.youtube.com/embed/zoo6WkY7ouc" frameborder="0" allowfullscreen></iframe><p><a href="https://www.youtube.com/user/NemoPostScriptum/videos" rel="nofollow" title="Subscribe Post Scriptum's Youtube Channel">Subscribe Post Scriptum's Youtube Channel</a></p>	</div>
<h2>Text Version</h2>
<h3>Step 1 – Adding the attachments</h3>
<p>Adding attachments with the proper name is fundamental for this technique. We will append the language ISOs to the names, so that they can later be targeted in the template.</p>
<p>Login to the back office, then navigate to Catalog &gt; Products, and choose one to start with. At the bottom of the <strong>Options </strong>tab, add two test attachments. The file names don’t matter, but the <strong>title </strong>you choose does. Add one attachment for each language it’s translated to, making sure you append the ISO code for that language after the name, like this: <strong>_en</strong>, <strong>_it</strong>, <strong>_fr</strong>.</p>
<p><strong>Note: </strong>If you don’t know what the language code is, hop to International &gt; Localization, and click on Languages. The ISO code is listed in the table:</p>
<p><a href="http://nemops.com/wp-content/uploads/2018/12/prestashop-17-language-iso.jpg"><img class="aligncenter size-full wp-image-3174" src="http://nemops.com/wp-content/uploads/2018/12/prestashop-17-language-iso.jpg" alt="PrestaShop 1.7 Language ISO" width="665" height="361" /></a></p>
<p>&nbsp;</p>
<p>If you need an attachment to display for all of the languages, make sure you <strong>do not</strong> add any language ISO to it.</p>
<div class="separator"></div>
<h3>Step 2 – Editing the template</h3>
<p>&nbsp;</p>
<p>For this tutorial I am using the “classic” template, that ships with PrestaShop 1.7. If you are using a custom theme, be aware that some of the code might be different, or even located in a different file.</p>
<p>Open up <strong>themes/classic/templates/catalog/product.tpl</strong>.</p>
<p>Locate the following code:</p>
<pre class="brush: php; html-script: true; title: ; notranslate">
{if $product.attachments}
                    &lt;div class=&quot;tab-pane fade in&quot; id=&quot;attachments&quot; role=&quot;tabpanel&quot;&gt;
                       &lt;section class=&quot;product-attachments&quot;&gt;
                         &lt;h3 class=&quot;h5 text-uppercase&quot;&gt;{l s='Download' d='Shop.Theme.Actions'}&lt;/h3&gt;
</pre>
<p>Right afterwards, but before the foreach loop, add the following</p>
<pre class="brush: php; html-script: true; title: ; notranslate">
{$lang_checker = &quot;_&quot;|cat: {$language.iso_code}}
{$lang_checker_array = ['en', 'it']}

</pre>
<p><strong>Make sure you use your own ISO codes instead of ‘en’ and ‘it’. Add all of the languages your store supports</strong></p>
<p>Next, wrap the attachment block in the following IF statement</p>
<pre class="brush: php; html-script: true; title: ; notranslate">
                         {if $attachment.name|strstr:{$lang_checker}}
                           &lt;div class=&quot;attachment&quot;&gt;
                             &lt;h4&gt;&lt;a href=&quot;{url entity='attachment' params=['id_attachment' =&gt; $attachment.id_attachment]}&quot;&gt;{$attachment.name|replace:{$lang_checker}:''}&lt;/a&gt;&lt;/h4&gt;
                             &lt;p&gt;{$attachment.description}&lt;/p
                             &lt;a href=&quot;{url entity='attachment' params=['id_attachment' =&gt; $attachment.id_attachment]}&quot;&gt;
                               {l s='Download' d='Shop.Theme.Actions'} ({$attachment.file_size_formatted})
                             &lt;/a&gt;
                           &lt;/div&gt;
{/if}

</pre>
<p>If you don’t need some attachments to display for all languages, you can go ahead and test it, as the basic part if basically done. If you do, you will need to add a little extra condition, and we will use that lang_checker_array for it.</p>
<div class="separator"></div>
<h3>Step 2.1 – Fallback for generic attachments</h3>
<p>Right before the end of the IF statement that checks for our ISO code, add the following:</p>
<pre class="brush: php; html-script: true; title: ; notranslate">

{else}
  {$denier = false}
  {foreach from=$lang_checker_array item=checkr_lang}
                              {if $attachment.name|strstr:{$checkr_lang}}
                              {$denier = true}
                              {/if}
  {/foreach}

</pre>
<p><strong>Explanation: </strong>We are setting a variable (denier) that will prevent displaying the attachment if it contains <strong>any</strong> language ISO. Because of this logic, make sure you use a string that’s unique enough in case your attachment names contain product codes or alike, otherwise they won’t ever display.</p>
<p>Right afterwards, but still inside our main IF, add this last chunk of code</p>
<pre class="brush: php; html-script: true; title: ; notranslate">
                               
{if !$denier}
&lt;div class=&quot;attachment&quot;&gt;
&lt;h4&gt;&lt;a href=&quot;{url entity='attachment' params=['id_attachment' =&gt; $attachment.id_attachment]}&quot;&gt;{$attachment.name|replace:{$lang_checker}:''}&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;{$attachment.description}&lt;/p
&lt;a href=&quot;{url entity='attachment' params=['id_attachment' =&gt; $attachment.id_attachment]}&quot;&gt;
{l s='Download' d='Shop.Theme.Actions'} ({$attachment.file_size_formatted})
&lt;/a&gt;
&lt;/div&gt;
{/if}

</pre>
<p>Which is basically a copy of the standard attachment code. If the attachment does not contain any iso code, it means we can display it normally.</p>
<p>We are done!</p>
<p>The post <a rel="nofollow" href="https://nemops.com/prestashop-1-7-multilanguage-attachments/">Creating Multilanguage attachments in PrestaShop 1.7</a> appeared first on <a rel="nofollow" href="https://nemops.com">NemoPS</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://nemops.com/prestashop-1-7-multilanguage-attachments/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Make product fields multi-language in PrestaShop and ThirtyBees</title>
		<link>https://nemops.com/prestashop-thirtybees-multi-language-product-fields/</link>
		<comments>https://nemops.com/prestashop-thirtybees-multi-language-product-fields/#comments</comments>
		<pubDate>Mon, 18 Sep 2017 02:56:55 +0000</pubDate>
		<dc:creator><![CDATA[Nemo]]></dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[language]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[prestashop]]></category>
		<category><![CDATA[products]]></category>
		<category><![CDATA[thirtybees]]></category>

		<guid isPermaLink="false">http://nemops.com/?p=3067</guid>
		<description><![CDATA[<p>In this tutorial we will learn how to make product fields translatable in PrestaShop 1.6, and see how to apply the method to the &#8220;price per&#8230;&#8221; field. Introduction You might have come across the need to translate the price per unit field in your PrestaShop or Thirtybees, but crashed against the software&#8217;s limitation, as that&#8217;s [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://nemops.com/prestashop-thirtybees-multi-language-product-fields/">Make product fields multi-language in PrestaShop and ThirtyBees</a> appeared first on <a rel="nofollow" href="https://nemops.com">NemoPS</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>In this tutorial we will learn how to make product fields translatable in PrestaShop 1.6, and see how to apply the method to the &#8220;price per&#8230;&#8221; field.<br />
<span id="more-3067"></span></p>
<h2>Introduction</h2>
<p>You might have come across the need to translate the price per unit field in your PrestaShop or Thirtybees, but crashed against the software&#8217;s limitation, as that&#8217;s a single language property. Any product field can be made multi-language with a simple modification, so let&#8217;s see how to do it using the Unity one as example in this tutorial!</p>
<div class="separator"></div>
<h2>Step 1 &#8211; Adding the new database column</h2>
<p>In order to make the field translatable, we have to add it to the <strong>product_lang </strong>table in the database. Not only, but  we also have to erase the same column in both the product and product_shop tables, to avoid conflicts when retrieving values from the database. Let&#8217;s add it first!</p>
<p>Using phpMyAdmin or Adminer, locate the <strong>*prefix*product_lang</strong> table in your database, and add a new column as <strong>VARCHAR</strong>, 24 characters long. Once done, it will look like this:</p>
<p><img src="http://nemops.com/wp-content/uploads/2017/09/multilang_field_db.png" alt="multilang_field_db" width="606" height="97" class="aligncenter size-full wp-image-3069" /></p>
<p>Next, let&#8217;s get rid of the leftovers: open the *prefix*product table and drop the <strong>unity</strong> column first, and then on the <strong>product_shop</strong> table.<br />
We are done! We just broke the Product class though, and have to compensate by letting it know where to grab the new values from.</p>
<div class="separator"></div>
<h2>Step 2 &#8211; Editing the product class</h2>
<p>We have a new column in the database, but at this point the Product class would still just ignore it. To have it lookup, and save into the correct table, we must tell it that the property we are wanting to translate is a multilanguage field. To do so, we must change its definition.</p>
<p>Open up <strong>Product.php</strong>, located in the <em>classes/</em> folder.</p>
<p>Scroll down until you find the following line, part of the <strong>$definition</strong> property:</p>
<pre class="brush: php; title: ; notranslate">
'unity'                     =&gt; ['type' =&gt; self::TYPE_STRING, 'shop' =&gt; true, 'validate' =&gt; 'isString'],
</pre>
<p>To make any field translatable, we can simply add &#8216;lang&#8217; => true as follows</p>
<pre class="brush: php; title: ; notranslate">
'unity'                     =&gt; ['type' =&gt; self::TYPE_STRING, 'shop' =&gt; true, 'validate' =&gt; 'isString', 'lang' =&gt; true],
</pre>
<p><strong>Please notice that, as always, using an override is strongly recommended, instead of editing core files.</strong></p>
<div class="separator"></div>
<h2>Step 3 &#8211; Editing the back office</h2>
<h3>The controller</h3>
<p>This is the most complicated part, as we will have to edit both the admin controller for products, and the correct template. For our example, the template is <strong>prices.tpl</strong>, but it will be different if the field you want to translate is in another tab.</p>
<p>Let&#8217;s start with the controller. The prices template does not offer us any option for translating fields, and therefore misses the indispensable $languages variable.<br />
Open up <strong>AdminProductsController</strong>, located in <em>controllers/admin</em></p>
<p>We are interested in the method called <strong>initFormPrices</strong>, so once you find it you can simply clone that to an override, or continue editing the core.</p>
<p>Right after $data is assigned, at the very beginning of the function, but <strong>before $product = $obj</strong>, add the following</p>
<pre class="brush: php; title: ; notranslate">
if (!$this-&gt;default_form_language) {
    $this-&gt;getLanguages();
}
$data-&gt;assign(array(
    'languages'=&gt; $this-&gt;_languages,
    'id_lang' =&gt; $this-&gt;context-&gt;language-&gt;id,
    'default_form_language' =&gt; $this-&gt;default_form_language,
));
</pre>
<p><strong>Explanation</strong>: Nothing too complex here, we are first checking if languages are loaded, and if not, assigning them to the controller. Then, we simply assign that class property to the template, along with a few other required ones. Please notice we do not use a common smarty assign, but the $data variable instead.</p>
<h3>The template</h3>
<p>Time to make our changes visible in the back office! For the unity field, let&#8217;s open up <em>*admin folder*/themes/default/template/controllers/products/prices.tpl</em></p>
<p>Locate the input with id unity, which will look more or less like the following:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;input id=&quot;unity&quot; name=&quot;unity&quot; type=&quot;text&quot; value=&quot;{$product-&gt;unity|htmlentitiesUTF8}&quot;  maxlength=&quot;255&quot; onkeyup=&quot;if (isArrowKey(event)) return ;unitySecond();&quot; onchange=&quot;unitySecond();&quot;/&gt;
</pre>
<p>Instead of this input, we will use a handy template PrestaShop makes available to us. Replace the above with the following code:</p>
<pre class="brush: php; title: ; notranslate">
{include file=&quot;controllers/products/input_text_lang.tpl&quot;
languages=$languages
input_class=&quot;{$class_input_ajax}{if !$product-&gt;id || Configuration::get('PS_FORCE_FRIENDLY_PRODUCT')}copy2friendlyUrl{/if} updateCurrentText&quot;
input_value=$product-&gt;unity
input_name=&quot;unity&quot;}
</pre>
<p>Save and refresh, and you will see the new field, translatable, appearing in the prices table of the back office. Time to test it, and see if it&#8217;s saving properly.<br />
We can take an extra step and translate the preview below as well:</p>
<pre class="brush: php; title: ; notranslate">
&lt;span id=&quot;unity_second&quot;&gt;{$product-&gt;unity}&lt;/span&gt;
</pre>
<p>to</p>
<pre class="brush: php; title: ; notranslate">
&lt;span id=&quot;unity_second&quot;&gt;{$product-&gt;unity.{$id_lang}}&lt;/span&gt;
</pre>
<p>At this point we can go ahead and test the Front Office. If everything has been done correctly, as soon as you change language, the class should automatically pick the correct translation for the field. Neat!</p>
<p>The post <a rel="nofollow" href="https://nemops.com/prestashop-thirtybees-multi-language-product-fields/">Make product fields multi-language in PrestaShop and ThirtyBees</a> appeared first on <a rel="nofollow" href="https://nemops.com">NemoPS</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://nemops.com/prestashop-thirtybees-multi-language-product-fields/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
