2017 © Pedro PelĂĄez
 

magento2-module magento2-module-translation

Extend magento translation system

image

shockwavedesign/magento2-module-translation

Extend magento translation system

  • Friday, June 2, 2017
  • by shockwavemk
  • Repository
  • 2 Watchers
  • 1 Stars
  • 126 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 7 Versions
  • 2 % Grown

The README.md

Magento2 Enhanced Translation

  • Copyright 2017 Shockwave-Design - J. & M. Kramer, all rights reserved.
  • For commercial use: Get a license on www.shockwave-design.de

Description

This module solves some major problems with Magento2 translation system., (*1)

First of all it solves the problem of cached JS-Translation files: Magento uses a cacheable json file for translations on forms., (*2)

These translations are stored in browser application cache:, (*3)

browser application local storage, (*4)

On the one hand this cache follows the idea to push translations to client only a few pageloads - on the other hand this behavior can produce difficulties for development. The system uses mage-translation-file-version to determine the need for refreshing the cache., (*5)

If you want to change a translation in a js-active form in magento2 sometimes you have to:, (*6)

  • Delete your browser cache
  • Delete your browser application storage
  • Flush the fullpage cache of M2
  • Flush the block / translation cache of M2

This process is acceptable if you just want to change one single translation, and your are aware of all these steps. Otherwise you have to debug all these steps - just looking for the one step you have missed out to change another translation., (*7)

Secondly - although you have managed to go through all your steps to translate your magento2 store to another locale - you have to search for each translation key., (*8)

Third - the structure of Magento2 language packages is a real disadvantage: A language pack does only contain a unordered list of translations in a csv., (*9)

This csv is really useful for agency translations and customizations of bought modules by external devs, cause its only one file - but there is a catch:, (*10)

If you have to define module scoped translations, for example for two translations with the same key, but different translations its impossible., (*11)

http://devdocs.magento.com/guides/v2.0/frontend-dev-guide/translations/xlate.html

Magento writes about this topic:, (*12)

Language packages that contain a entire dictionary in one directory.

You can distribute this language package as a standalone component (similar to modules and themes). Interestingly, it violates Magento’s modularity principles on purpose; that is, so that a system integrator can translations variations provided by extensions.

But what to do, if i need both: module structured translations AND one language pack for each locale?, (*13)

Features

This module enables the frontend-developer to set a cookie, which: - disables the cache in client web browser, the translation json file is generated every load - shows not only the translation on frontend, but also the key used, (*14)

Language

Changes of shop behavior

The language pack load procedure is enhanced backward compatible. It will load existing and enhanced language packs., (*15)

Configuration

Create an enhanced language pack

Create a new language pack as documented here:, (*16)

http://devdocs.magento.com/guides/v2.0/frontend-dev-guide/translations/xlate.html

Then create a subfolder for each vendor scope you want to override e.g. magento, youragency ..., (*17)

Create a folder called i18n in it and then a file called like the locale you want to override., (*18)

, (*19)

In this csv file you can translate all values as in magento2 default:, (*20)

Remove,"Entfernen"
Cancel,"Abbrechen"
"Manage Shopping Cart","Warenkorb bearbeiten"
"Create Order","Neue Bestellung"
Back,"ZurĂŒck"
"Add Products","Artikel hinzufĂŒgen"
"Update Items and Qty's","Aktualisieren"
"Are you sure you want to clear your shopping cart?","Sind Sie sicher, dass sie alle Artikel aus dem Warenkorb entfernen möchten?"
"Clear the shopping cart.","Warenkorb leeren."
"Add Selected Product(s) to Shopping Cart","AusgewÀhlte Artikel in den Warenkorb legen"
"Shopping Cart for %1 in %2","Shopping Cart for %1 in %2"
"Choose  products to add to shopping cart.","Artikel auswÀhlen, um sie in den Warenkorb zu legen."
Product,Produkt

This module will sort the order of defined modules according to the module dependency list, read its content and will add it to the result set., (*21)

Example:, (*22)

  • module-catalog defines a translation for key/value "Always,Immer"
  • module-checkout defines a translation for key/value "Always,Jederzeit"

The current controller scope is module-checkout., (*23)

Then all translations are loaded first module-catalog and then as last module: module-checkout, because its the current scope. Result: "Jederzeit" is displayed., (*24)

Just do this simple steps: - deactivate frontend cache for block, translation and full_page - set a cookie called "debugTranslationHints" and value "true" in your browser, (*25)

, (*26)

The result should look like this:, (*27)

, (*28)

All translations used in blocks are enhanced by brackets [] and contain key and translation value if given., (*29)

, (*30)

Dependencies to third party

No dependencies to third party modules or services., (*31)

The Versions

02/06 2017

dev-develop

dev-develop

Extend magento translation system

  Sources   Download

unlicensed

02/06 2017

dev-master

9999999-dev

Extend magento translation system

  Sources   Download

unlicensed

02/06 2017

v0.2.2

0.2.2.0

Extend magento translation system

  Sources   Download

unlicensed

02/06 2017

dev-feature/updated-documentation

dev-feature/updated-documentation

Extend magento translation system

  Sources   Download

unlicensed

19/08 2016

v0.2.1

0.2.1.0

Extend magento translation system

  Sources   Download

unlicensed

19/08 2016

v0.2.0

0.2.0.0

Extend magento translation system

  Sources   Download

unlicensed

19/08 2016

v0.1.0

0.1.0.0

Extend magento translation system

  Sources   Download

unlicensed