Jump to content

have installed 1.7 looks very good - how could i change the frontend into german


ppeter

Recommended Posts

I'm surprised to see your main menu working. Didn't work here, I had to hack it severely, essentially rewriting it. Did you hack it, too?

 

Then you apparently managed to put products into categories. Was this done with 1.7, too, or is this a copy of an older database? So far I couldn't find a way to put products into categories on 1.7.

 

Perhaps all this because you kept the demo data? Because you kept all the modules? Did this just work out?

 

Regarding translations: as far as I can see, there are currently no translations at all. All the en.php and de.php files are zero size. But during use (just klick around in the shop) a file gets created, app/logs/dev.log. This logs every missing translation with useful hints and the "only" challenge would be to find out which of these empty language files to put the translation into.

Link to comment
Share on other sites

Hi!

 

have installed 1.7 looks very good - how could i change the frontend into german

http://to-create.eu/wetterinstrumente/

 

thx

Peter

This is just a slightly improved beta. :)

Like every other language the German translation is currently far from being complete. Hundreds of translation items are missing. And from my experience as proof reader for the German translation I guess it'll take much time to complete it.

In the meantime you may do it yourself using the translation facilities in the back office:

LOKALISIERUNG --> ÜBERSETZUNGEN
You need to translate the modules and some minor parts of the front office first.
Link to comment
Share on other sites

Perhaps I should apply as bug-hunter over at PrestaShop SA, but translating via tha database doesn't work either for me. Lots of error messages and what appears after this misses the messages I'm looking for.

 

So I whipped up a quick patch to get translations working via files. A couple of english -> english translations already applied to not overwhelm you with all the messages about missing one. Add translations as they're reported as missing. For production or when visiting back-office, turn them off by commenting out the changed line MessageCatalogue.php.

 

Please find the patch attached :-)

 

Well, "not allowed to upload this kind of file", so let's put this in directly:

 

From 023824034072e7c55fe443ae963632df8b193367 Mon Sep 17 00:00:00 2001
From: Markus Hitter <[email protected]>
Date: Mon, 8 Aug 2016 17:40:53 +0200
Subject: Translations: quick shot to get this working at all.

 - Use PHP instead of XLIFF to allow reasonable editing in a
   text-editor. XLIFF is very complex.

 - Extract domain names from file names properly. Before, no dots
   in domain names were allowed, still PrestaShop uses such dots
   everywhere.

 - Also added a couple of translations. Add more as they show up.

 - One line in MessageCatalogue writes about missing translations.
   For production this should be turned off, of course.
---
 .../translations/Modules.BlockCart.Admin.en-US.php |  8 +++++
 .../translations/Modules.CustomText.en-US.php      |  8 +++++
 .../translations/Modules.CustomerSignIn.en-US.php  |  8 +++++
 .../Modules.FeaturedProducts.Admin.en-US.php       |  8 +++++
 .../translations/Modules.ImageSlider.en-US.php     |  8 +++++
 .../Modules.SocialFollow.Admin.en-US.php           |  8 +++++
 .../translations/Shop.Theme.Actions.en-US.php      |  7 ++++
 .../translations/Shop.Theme.Catalog.en-US.php      | 16 ++++++++++
 .../translations/Shop.Theme.Checkout.en-US.php     | 12 +++++++
 app/Resources/translations/Shop.Theme.en-US.php    |  9 ++++++
 app/Resources/translations/messages.en-US.php      | 15 +++++++++
 classes/Context.php                                | 37 ++++++++++++----------
 .../Component/Translation/MessageCatalogue.php     |  1 +
 13 files changed, 129 insertions(+), 16 deletions(-)
 create mode 100644 app/Resources/translations/Modules.BlockCart.Admin.en-US.php
 create mode 100644 app/Resources/translations/Modules.CustomText.en-US.php
 create mode 100644 app/Resources/translations/Modules.CustomerSignIn.en-US.php
 create mode 100644 app/Resources/translations/Modules.FeaturedProducts.Admin.en-US.php
 create mode 100644 app/Resources/translations/Modules.ImageSlider.en-US.php
 create mode 100644 app/Resources/translations/Modules.SocialFollow.Admin.en-US.php
 create mode 100644 app/Resources/translations/Shop.Theme.Actions.en-US.php
 create mode 100644 app/Resources/translations/Shop.Theme.Catalog.en-US.php
 create mode 100644 app/Resources/translations/Shop.Theme.Checkout.en-US.php
 create mode 100644 app/Resources/translations/Shop.Theme.en-US.php
 create mode 100644 app/Resources/translations/messages.en-US.php

diff --git a/app/Resources/translations/Modules.BlockCart.Admin.en-US.php b/app/Resources/translations/Modules.BlockCart.Admin.en-US.php
new file mode 100644
index 0000000..245f641
--- /dev/null
+++ b/app/Resources/translations/Modules.BlockCart.Admin.en-US.php
[spam-filter] -0,0 +1,8 [spam-filter]
+<?php
+
+return array(
+  'Cart block' => 'Cart block',
+  'Adds a block containing the customer\'s shopping cart.' => 'Adds a block containing the customer\'s shopping cart.',
+);
+
+?>
diff --git a/app/Resources/translations/Modules.CustomText.en-US.php b/app/Resources/translations/Modules.CustomText.en-US.php
new file mode 100644
index 0000000..168800d
--- /dev/null
+++ b/app/Resources/translations/Modules.CustomText.en-US.php
[spam-filter] -0,0 +1,8 [spam-filter]
+<?php
+
+return array(
+  'Custom text' => 'Custom text',
+  'Adds custom text in your store.' => 'Adds custom text in your store.',
+);
+
+?>
diff --git a/app/Resources/translations/Modules.CustomerSignIn.en-US.php b/app/Resources/translations/Modules.CustomerSignIn.en-US.php
new file mode 100644
index 0000000..cfbd0cc
--- /dev/null
+++ b/app/Resources/translations/Modules.CustomerSignIn.en-US.php
[spam-filter] -0,0 +1,8 [spam-filter]
+<?php
+
+return array(
+  'Customer "Sign in" link' => 'Customer "Sign in" link',
+  'Adds a block that displays information about the customer.' => 'Adds a block that displays information about the customer.',
+);
+
+?>
diff --git a/app/Resources/translations/Modules.FeaturedProducts.Admin.en-US.php b/app/Resources/translations/Modules.FeaturedProducts.Admin.en-US.php
new file mode 100644
index 0000000..febb07c
--- /dev/null
+++ b/app/Resources/translations/Modules.FeaturedProducts.Admin.en-US.php
[spam-filter] -0,0 +1,8 [spam-filter]
+<?php
+
+return array(
+  'Featured products' => 'Featured Products',
+  'Displays featured products in the central column of your homepage.' => 'Displays featured products in the central column of your homepage.',
+);
+
+?>
diff --git a/app/Resources/translations/Modules.ImageSlider.en-US.php b/app/Resources/translations/Modules.ImageSlider.en-US.php
new file mode 100644
index 0000000..a857776
--- /dev/null
+++ b/app/Resources/translations/Modules.ImageSlider.en-US.php
[spam-filter] -0,0 +1,8 [spam-filter]
+<?php
+
+return array(
+  'Image slider' => 'Image slider',
+  'Adds an image slider to your site.' => 'Adds an image slider to your site.',
+);
+
+?>
diff --git a/app/Resources/translations/Modules.SocialFollow.Admin.en-US.php b/app/Resources/translations/Modules.SocialFollow.Admin.en-US.php
new file mode 100644
index 0000000..14f2eea
--- /dev/null
+++ b/app/Resources/translations/Modules.SocialFollow.Admin.en-US.php
[spam-filter] -0,0 +1,8 [spam-filter]
+<?php
+
+return array(
+  'Social media follow links' => 'Social media follow links',
+  'Allows you to add information about your brand\'s social networking accounts.' => 'Allows you to add information about your brand\'s social networking accounts.',
+);
+
+?>
diff --git a/app/Resources/translations/Shop.Theme.Actions.en-US.php b/app/Resources/translations/Shop.Theme.Actions.en-US.php
new file mode 100644
index 0000000..ce086e7
--- /dev/null
+++ b/app/Resources/translations/Shop.Theme.Actions.en-US.php
[spam-filter] -0,0 +1,7 [spam-filter]
+<?php
+
+return array(
+  'Sign in' => 'Login',
+);
+
+?>
diff --git a/app/Resources/translations/Shop.Theme.Catalog.en-US.php b/app/Resources/translations/Shop.Theme.Catalog.en-US.php
new file mode 100644
index 0000000..01d5560
--- /dev/null
+++ b/app/Resources/translations/Shop.Theme.Catalog.en-US.php
[spam-filter] -0,0 +1,16 [spam-filter]
+<?php
+
+return array(
+  'Discount' => 'BlaBa in Shop.Theme.Catalog.en-US.php',
+  'All products' => 'All Products',
+  'Relevance' => 'Relevance',
+  'Name, A to Z' => 'Name, A to Z',
+  'Name, Z to A' => 'Name, Z to A',
+  'Price, low to high' => 'Price, low to high',
+  'Price, high to low' => 'Price, high to low',
+  'New' => 'New',
+  'Search our catalog' => 'Search our catalog',
+  'Popular Products' => 'Popular Products',
+);
+
+?>
diff --git a/app/Resources/translations/Shop.Theme.Checkout.en-US.php b/app/Resources/translations/Shop.Theme.Checkout.en-US.php
new file mode 100644
index 0000000..72196a9
--- /dev/null
+++ b/app/Resources/translations/Shop.Theme.Checkout.en-US.php
[spam-filter] -0,0 +1,12 [spam-filter]
+<?php
+
+return array(
+  'Cart' => 'Cart',
+  'Subtotal' => 'Subtotal',
+  'Shipping' => 'Shipping',
+  'Free' => 'Free',
+  'Total' => 'Total',
+  '1 item' => '1 item',
+);
+
+?>
diff --git a/app/Resources/translations/Shop.Theme.en-US.php b/app/Resources/translations/Shop.Theme.en-US.php
new file mode 100644
index 0000000..dd60378
--- /dev/null
+++ b/app/Resources/translations/Shop.Theme.en-US.php
[spam-filter] -0,0 +1,9 [spam-filter]
+<?php
+
+return array(
+  'Home' => 'Home',
+  '(tax incl.)' => 'tax incl.',
+  '(tax included)' => 'tax included',
+);
+
+?>
diff --git a/app/Resources/translations/messages.en-US.php b/app/Resources/translations/messages.en-US.php
new file mode 100644
index 0000000..0aac24c
--- /dev/null
+++ b/app/Resources/translations/messages.en-US.php
[spam-filter] -0,0 +1,15 [spam-filter]
+<?php
+
+return array(
+  'Quick search block' => 'Quick search block',
+  'Adds a quick search field to your website.' => 'Adds a quick search field to your website.',
+  'Language selector block' => 'Language selector block',
+  'Adds a block allowing customers to select a language for your store\'s content.' => 'Adds a block allowing customers to select a language for your store\'s content.',
+  'Currency block' => 'Currency block',
+  'Adds a block allowing customers to choose their preferred shopping currency.' => 'Adds a block allowing customers to choose their preferred shopping currency.',
+  'Main menu' => 'Main menu',
+  'Adds a new menu to the top of your e-commerce website.' => 'Adds a new menu to the top of your e-commerce website.',
+  'My Account block' => 'My Account block',
+);
+
+?>
diff --git a/classes/Context.php b/classes/Context.php
index 1f52136..b777aad 100644
--- a/classes/Context.php
+++ b/classes/Context.php
[spam-filter] -25,7 +25,7 [spam-filter]
  */
 
 use Symfony\Component\Finder\Finder;
-use Symfony\Component\Translation\Loader\XliffFileLoader;
+use Symfony\Component\Translation\Loader\PhpFileLoader;
 use PrestaShopBundle\Translation\TranslatorComponent as Translator;
 use PrestaShopBundle\Translation\Loader\SqlTranslationLoader;
 
[spam-filter] -340,24 +340,29 [spam-filter] class ContextCore
     public function getTranslator()
     {
         if (null === $this->translator) {
-            $this->translator = new Translator($this->language->locale, null, _PS_CACHE_DIR_, false);
-            $this->translator->addLoader('xlf', new XliffFileLoader);
+            $this->translator = new Translator($this->language->locale, null, null, false);
+            // Use PHP file format instead of the human-unfriendly XLIFF.
+            $this->translator->addLoader('php', new PhpFileLoader);
             $this->translator->addLoader('db', new SqlTranslationLoader);
 
-            $finder = Finder::create()
-                ->files()
-                ->filter(function (\SplFileInfo $file) {
-                    return 2 === substr_count($file->getBasename(), '.') && preg_match('/\.\w+$/', $file->getBasename());
-                })
-                ->in(_PS_ROOT_DIR_.'/app/Resources/translations')
-            ;
-
-            foreach ($finder as $file) {
-                list($domain, $locale, $format) = explode('.', $file->getBasename(), 3);
-
-                $this->translator->addResource($format, $file, $locale, $domain);
-                $this->translator->addResource('db', $domain.'.'.$locale.'.db', $locale, $domain);
+            // Use much less complex direct PHP functions to find resources.
+            $dirname = _PS_ROOT_DIR_ . '/app/Resources/translations';
+            $dir = opendir($dirname);
+            while (false !== ($file = readdir($dir))) {
+                $nameparts = explode('.', basename($file));
+                $npcount = count($nameparts);
+                if ($npcount >= 3 && $nameparts[0] != '') {
+                    list($domain, $locale, $format) = $nameparts;
+
+                    $format = $nameparts[$npcount - 1];
+                    $locale = $nameparts[$npcount - 2];
+                    $domain = implode('.', array_slice($nameparts, 0, $npcount - 2));
+
+                    $this->translator->addResource($format, $dirname.'/'.$file, $locale, $domain);
+                    $this->translator->addResource('db', $domain.'.'.$locale.'.db', $locale, $domain);
+                }
             }
+            closedir($dir);
         }
 
         return $this->translator;
diff --git a/vendor/symfony/symfony/src/Symfony/Component/Translation/MessageCatalogue.php b/vendor/symfony/symfony/src/Symfony/Component/Translation/MessageCatalogue.php
index dd354a8..d3d8a11 100644
--- a/vendor/symfony/symfony/src/Symfony/Component/Translation/MessageCatalogue.php
+++ b/vendor/symfony/symfony/src/Symfony/Component/Translation/MessageCatalogue.php
[spam-filter] -112,6 +112,7 [spam-filter] class MessageCatalogue implements MessageCatalogueInterface, MetadataAwareInterf
             return $this->fallbackCatalogue->get($id, $domain);
         }
 
+print('<pre>Translation for \''.$id.'\' not found in domain \''.$domain."'.</pre>\n");
         return $id;
     }
 
--
2.7.4
 

Kleingedrucktes: as I have no idea of what PrestaShop's plans are, the translation mechanism in later PS versions might come out very differently from what I did.

Link to comment
Share on other sites

Nice try - but what is it good for?

 

Seems you missed one important fact - the symfony translation facility wouldn't find any translation item yet, because all items are still stored in php files working with the old translation system still implemented in 1.7 beta. The ressources folder is empty.

Even new developped modules still ignore the new xml structure, you find in construction at Crowdin.

I have no idea when the PrestaShop developer team will make this work in PrestaShop - perhaps  with release 1.8.0.15? :rolleyes:

 

And, btw ... parts of your code didn't pass the forum bad word filters. (Search for [spam filter]) :)

Link to comment
Share on other sites

 

 

but what is it good for?

Now I can translate phrases. That's the point of a translation system, isn't it?

 

Seems you missed one important fact - the symfony translation facility wouldn't find any translation item yet

It does find these items.

 

The old translation system might work, too, but finding out how to put a string in there was more difficult than writing the new code.

 

parts of your code didn't pass the forum bad word filters.

Obviously not a filter written by me.

Link to comment
Share on other sites

 

+++ b/app/Resources/translations/Shop.Theme.Checkout.en-US.php

[spam-filter] -0,0 +1,12 [spam-filter]

 

....

 

+++ b/app/Resources/translations/Modules.BlockCart.Admin.en-US.php

[spam-filter] -0,0 +1,8 [spam-filter]

 

....

 

[spam-filter] -112,6 +112,7 [spam-filter] class MessageCatalogue implements MessageCatalogueInterface, MetadataAwareInterf

             return $this->fallbackCatalogue->get($id, $domain);

 

Just three examples. You'll find more when searching. ;)

Which means, nobody but you can use this code.

 

Anyway, I must admit that I missed the release of beta 3, which comes along with some added translation domains.

Link to comment
Share on other sites

Which means, nobody but you can use this code.

Did you write a bug report about this malfunctioning filter already? Did you write a report against the disallowance to upload .patch files? Or do you consider everybody else as too stupid to fix these [entries] before applying the patch? Or do you feel bad because somebody else wrote working code? Or what is your point?

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...