Jump to content

Um, how do phrases in translations work


MostlyConfused

Recommended Posts

Every now and then, I translate parts of CC to German.

The general process is very easy.

But for instance: When I have subcategories and check the shop on the phone, navigating into a category adds a listitem "Back" to the top.

I want to translate this to the German "zurück".

I went through all the sections in Admin>Languages, but no entry or translation exists for this.

In definitions.xml however, there is a line

<string name="back" introduced="6.0.11"><![CDATA[Back]]></string>

Why is this line only there and not in my de-DE.xml ?
How do I get it there?
How do definitions.xml and the language file like de-DE.xml actually work together?

I tried copying this line to my de-DE.xml, but it still did not show up for translation in the group I put it to.

Thanks

Link to comment
Share on other sites

If making changes to the language phrases, regardless where or how, be sure to clear CubeCart's cache.

CubeCart first loads definitions.xml and caches two variations of it (the details not important).

CubeCart then loads the targeted language file (for example en-US.xml). Same-key phrases are overwritten. For example, the key 'mobile' has US English "Cell Phone" as what gets displayed. Also, 'postcode' is displayed as "Zip Code". An entire language pack will overwrite whatever same-keys exist in that pack, while missing keys will cause CubeCart to use those default phrases.

Using the admin's Language editor, changes and customizations are stored in the database (to survive upgrades). This is the last of the overwrites.

The phrase key 'back' (in the "common" group) is not in a language pack because almost all language packs were created in the very early versions of CubeCart5. The key 'back' was introduced in CC6011.

As new features are added to CubeCart, requiring new phrases, only the definitions.xml (and perhaps en-UK.xml) will get updated as necessary.

I'm sure CubeCart HQ would appreciate having a sponsor for a language pack, to keep it up to date.

Link to comment
Share on other sites

Would this work:
Copy definitions.xml and rename it to de-DE.xml

Translate everything in it and use it as CC's new german language file?

If so, this would even be easier for me. I could edit the file directly instead of doing it in sections over the admin.

Right now I am sticking to more or less translating what I need in the Frontend. I'll keep the admin in English, since the current translation is first lousy and even more important phrases get longer than the English one and break the layout.

If I had only one file to directly edit, it would be that much easier that I would possible translate everything at once.

Link to comment
Share on other sites

You could do that with the following proviso:

Note the difference in the structure of the two files. The definitions.xml file has <group> nodes and are enclosed within a <definitions> node. The language pack has <group> nodes enclosed within a <translation> node, and along with a sibling <info> node, are enclosed within a <language> node.

 

Link to comment
Share on other sites

15 minutes ago, bsmither said:

You could do that with the following proviso:

Note the difference in the structure of the two files. The definitions.xml file has <group> nodes and are enclosed within a <definitions> node. The language pack has <group> nodes enclosed within a <translation> node, and along with a sibling <info> node, are enclosed within a <language> node.

 

Let me put this another way.
Is there any kind of file that I could use as a base for my translation that includes ALL phrases there are, without converting or changing first?
Or would it be enough to change every instance of <definitions> to <translation> in definitions.xml?

Link to comment
Share on other sites

Do not change the structure or name of the definitions.xml file.

I am not finding a way to properly merge de-DE.xml and definitions.xml into one file. I suppose it could be done with an XML file manager.

Let me think about this a bit.

At least, when editing a language in admin, there is the "Merge to file" tab, which will create a new file, de-DE-custom.xml, that will contain the original de-DE.xml phrases, but having any customizations that were databased be incorporated. Unfortunately, the custom file will not have any of the newer keys added to definitions.xml.

 

Link to comment
Share on other sites

If I understand you right, this seems like a mayor drawback then?

How would one ever have all phrases available, if the language file is not brand new?
How would I upgrade CC with possible new phrases to translate?

I can totally hack and force my way through the current project and get everything I need.

Since I've gotten so much help here, I'd like to repay that a bit and bring the German translation up to date.
But there needs to be a way that others can really use my translation and are not missing anything, just because CC might have been upgraded or something.

I tried creating a new language de-DE. In this new version, there is common -> "back" to translate.
The new file itself is tiny. Merge to file is tiny too.
I suppose this will grow bigger, as more phrases get translated?
Starting over from scratch would be the last resort if there is no other way to merge the already translated phrases with the ones missing.

 

EDIT, a while later:

The more I try, the more I get confused by how this works.

Somehow, by downloading language files from my shop or by merging, I finally got the "back" phrase to translate in Common.
No hacking or funny stuff, I just used CC's functions for this.

So I translated it, but still the English phrase shows up instead.
I checked and doublechecked, switched languages forth and back, cleared the cache a million times, but it stubbornly stays English.

In my current de-DE.xml the phrase ist there.
Inside CC's language-section, the phrase is there.
In the Frontend it still shows "Back".

Please see screenshots:

back1.png.151c68ed8a0bb9f2b52e28b4e5beb86e.png

 

back2.thumb.png.d799df147e87f21476fada1452ad1b97.png

 

back3.png.b2c9021926c5a2e8179e905eb62f363a.png 

Link to comment
Share on other sites

I've been looking at XML file merge utilities. I should have an answer to that tomorrow. The intent is to merge into the de-DE.xml file, any and all keys from definitions.xml not present in de-DE.xml.

From where I sit, I see Cubecart's perspective, and thus perhaps from HQ's perspective as regards CubeCart as well, developing a robust language pack is a Developer's job. Not so much a store owner's job. A Developer needs developer tools, and CubeCart isn't that.

"How would one ever have all phrases available, if the language file is not brand new?"

The definitions.xml file "fills in the blanks," admittedly, with UK-oriented phrases, which are overwritten by the databased entries.

The functions to export and import language files solves the need to transport customizations from one store to another.

 

 

Link to comment
Share on other sites

Here is a zipped language file that has as it's initial source, the original de-DE.xml file, then has your updated phrases overwritten same-name keys and added new-name keys from your custom file, then has added all new-name keys from CC624's definitions.xml file.

Using a programmer's text editor (i.e., not Notepad), note the <string> lines that have no leading spaces. Those are the new phrases that have been added from definitions.xml.

Thank you so much for your efforts!

de-DE-definitions-merged.zip

Link to comment
Share on other sites

Please don't thank me, you have done so much, it's only fair that I help too if I can.

That said, thanks again for the file. Imported it and of course it works.
But either I have discovered a bug, or there is something else I don't know.

The stubborn "Back" in the mobile navigation is still there, even though in the language file it's set as "zurück".
Just for fun, I changed it to "zurück" in the English file too.

Switched to English and hey presto ... still "Back", unbothered as it can be.

So I dug further and found the JS that creates this menu.

I understand JS enough to get a general impression of what it does. I'm not experienced enough however to go debugging from there.

I believe the "Back" is generated by this line:

$('h5>a', $titleLi).html(settings.back_text);

Here is the bigger picture:

backtext.png.0e83f24b1a6d40155a0b59a2dce97b70.png

 

In the same file I found this.
If I cange the "Back" in the JS, it shows in the navigation.
So maybe for some reason, CC does not "know" there is a custom text?

backtext2.png.de2c6a5df373c7c44cb549a0ffc63785.png

Link to comment
Share on other sites

Excellent sleuthing!

In the Foundation template main.php, make sure this is there:

Near line 59:

            <div class="row small-collapse">
               <div class="small-12 columns">
                  {include file='templates/box.navigation.php'}
                  <div class="hide" id="val_lang_back">{$LANG.common.back}</div>
               </div>
            </div>

This is necessary for one of the two approaches to work.

The first approach would be this:

In box.navigation.php, find:

<nav class="top-bar category-nav" data-topbar="" id="box-navigation">

Change to:

<nav class="top-bar category-nav" data-topbar data-options="back_text:{$LANG.common.back}" id="box-navigation">

Clear Cubecart's cache.

The other approach is to edit the last line of element.js_foot.php.

Find this part:

$(document).foundation({equalizer:{equalize_on_stack:true}});

Change that part to:

$(document).foundation({topbar{back_text:$('#val_lang_back').text()}},{equalizer:{equalize_on_stack:true}});

I haven't tried any of this, so if it works, we will post an issue about it in the GitHub.

Link to comment
Share on other sites

I am thinking your Foundation skin is not current (shipped with CC642).

From your screengrab, the Topbar is v5.5.1, while CC642's is v5.5.2.

There is also:

  var back_text = $('#val_lang_back').text();
  if(!back_text) {
    back_text = 'Back';
  }

  Foundation.libs.topbar = {
    name : 'topbar',

    version : '5.5.2',

    settings : {
      index : 0,
      start_offset : 0,
      sticky_class : 'sticky',
      custom_back_text : true,
      back_text : back_text,
      mobile_show_parent_link : false,

This finds the language string (which we did earlier), and uses it if present.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...