16 Replies Latest reply: Nov 15, 2013 12:04 AM by WJBroer RSS

    Translation of messages which can't be controlled in the online-shop.js.

    Frank Grootaarts Community Member

      Hello there,

       

      Is there someone who can make a good description/example on how to translate the system-messages? There is a turtorial which uses a online-shop.js (http://forums.adobe.com/docs/DOC-1808 from Mario) to translate the custom messages, but not all system-messages can be controlled here.

       

      We really need help here, because for us (non-english website builders) this is really important. We simply need to translate those messages.

       

      Maybe it's an good idea to make a turtorial/overview to translate all the rendered english messages. Like these one which are not controlled in the online-shop.js file.:

       

      1. "shopping cart is empty" in the module: {module_shoppingcartsummary,vertical,}
      2. "No one logged in. Log in" in the module: {module_whosloggedin,}
      3. "Choose shipping option" in the cart {tag_shippingoptions}
      4. "--Please select--" in the {tag_shippingoptions}
      5. "Shipping option selected succesfully" In the shopping_cart module template.
      6. "Discount code used is either invalid or expired." in the shopping_cart module template.
      7. "Gift voucher code used is invalid. in the shopping_cart module template.
      8. "No products found matching your query." in the {module_productresults}
      9. "No results matching your query" in the {module_searchresults}

       

      There are a view more system messages which can't be controlled in the online-shop.js

       

      Feel free to add them here if you find any. Because for non-english sites it is very important to get a good turtorial/solution for this. And a lot of people will be helped that way.

       

      Thanks,

       

      Frank

        • 1. Re: Translation of messages which can't be controlled in the online-shop.js.
          shannesunonsen Community Member

          Hello everyone

          I support Franks proposal! (I'm Danish).
          I think BC is great, but in the above mentioned issues it’s a bit tricky to use for developing non-English sites.
          Maybe a special forum to share workarounds for translating the tricky parts would be an idea?

          I sure hope the guys at BC will take an interest in this matter, and I too would love to see a tutorial.

          Hopefully
          /Shanne

          • 2. Re: Translation of messages which can't be controlled in the online-shop.js.
            Frank Grootaarts Community Member

            I Found another one:

             

            10. "Shopping cart is empty. Continue Shopping" in the shopping_cart module template.

             

            Just to make it more complete.

            • 3. Re: Translation of messages which can't be controlled in the online-shop.js.
              shannesunonsen Community Member

              One more:

               

              11. "This product has no related products." in the {tag_relatedproducts}

              • 4. Re: Translation of messages which can't be controlled in the online-shop.js.
                mario_gudelj CommunityMVP

                Frank and Shanne, thanks for posting these strings. Please keep them coming. I'll send this topic to our product management.

                 

                Cheers,

                 

                -mario

                • 5. Re: Translation of messages which can't be controlled in the online-shop.js.
                  Frank Grootaarts Community Member

                  After searching for a solution i have found the issue. Here is what happens:

                   

                  My test/system site shows the rendered messages in dutch:

                   

                  Schermafbeelding 2012-11-13 om 6.12.49 PM.png

                  This is because the system renders a language-script like this:

                   

                  Schermafbeelding 2012-11-13 om 6.12.23 PM_pijl.png

                   

                  Notice the jslang='NL'

                   

                  The live site under the domainname grootaarts-nijmegen.nl renders messages in English:

                   

                  Schermafbeelding 2012-11-13 om 6.13.27 PM.png

                  This is because the system renders a language-script like this:

                   

                  Schermafbeelding 2012-11-13 om 6.13.15 PM_pijl.png

                   

                  Notice the jslang='EN'

                   

                  This is controled in the admin: site settings/site domains here you choose a Culture. The problem is that Dutch (The Netherlands) and also Danish (Denmark) are missing in the Culture. So we can't choose them and that gives us the problem.

                   

                  If i could choose Dutch (The Netherlands) then my problem is solved that is clear. And i can live with that, although i haven't any control over the messages (maybe i want some other dutch text to be rendered).

                   

                  So i hope BC will add a Dutch and Danish module for me and Shane very fast. So we can build sites in our own language!

                  • 6. Re: Translation of messages which can't be controlled in the online-shop.js.
                    ndkamp Community Member

                    Hi Frank

                     

                    I'm posting this as a response to the partner inquiry you sent me.

                     

                    I had the same problem as you, when creating this site.

                     

                    Unfortunately, as of now, BC has no proper internationalization support. There are many inconsistencies regarding message and system strings, formats and where they might be configured. The current team is not to blame, they inherited that codebase.

                     

                    Nevertheless, a solution to the problem is to override certain strings after the page has loaded using javascript, jQuery ot the like.

                    BC holds an Object with system messages in a variable Oshoplang in the window(!) namespace.

                    You may want to call a function as the one below to override the system messages that may occur when BC makes AJAX-Calls. For cocomoshi, I localized the messages as below:

                     

                    var localizeSystemMessages = function () {

                    /*overwrite BC system messages */

                    window.Oshoplang = {  RemoveError: 'Um Mengen zu entfernen oder zu aktualisieren, wählen Sie den Link Einkaufstasche anzeigen.',

                    Added: ' Objekt(e) wurden Ihrem Einkaufswagen hinzugefügt',  OutOfStock: 'Das Produkt ist ausverkauft oder nicht mehr in der gewünschten Menge auf Lager. Bitte wählen Sie gegebenenfalls eine kleinere Menge.',

                    PreOrder: 'Objekt(e) vorbestellt und Ihrem Einkaufswagen hinzugefügt.',

                    MinLimit: 'Die eingegebene Menge ist zu klein, geben Sie bitte eine größere Menge ein.',

                    MaxLimit: 'Die eingegebene Menge ist zu groß, geben Sie bitte eine kleinere Menge ein.',

                    InvalidQuantity: 'Die eingegebene Menge ist ungültig.',

                    CartEmpty: 'Ihr Einkaufswagen ist leer.',

                    CartUpdateSuccess: 'Der Einkaufswagen wurde erfolgreich aktualisiert.',

                    InvalidShip: 'Bitte wählen Sie eine gültige Versand-Option.',

                    ChooseState: 'Bitte wählen Sie einen Bestimmungs-Staat um die Staatssteuer zu berechnen.',

                    EnterZip: 'Bitte geben Sie Ihre Postleitzahl ein um die Versandkosten für Ihren Auftrag zu berechnen.',

                    ChooseShip: 'Bitte wählen Sie eine Versandkostenart für Ihren Auftrag.',

                    IncorrectGForm: 'Ihr Geschenkgutschein-Formular ist nicht richtig aufgesetzt. Bitte setzen Sie es auf Original zurück um es wiederherzustellen.',

                    EnterGName: 'Bitte geben Sie einen Namen für den Empfänger Ihres Geschenkgutscheins ein.',

                    InvalidGEmail: 'Bitte geben Sie eine gültige Email-Adresse für den Empfänger Ihres Geschenkgutscheins ein.',

                    EnterGMessage: 'Bitte geben Sie eine persönliche Mitteilung für den Empfänger Ihres Geschenkgutscheins ein.',

                    ChooseAttribute: 'Vor dem Hinzufügen in den Warenkorb wählen Sie bitte die entsprechenden Optionen.'  };

                    }

                     

                    Not all of the messages can be handled like this.  You might want to use jQuery selectors to specifically override Strings after the page has loaded. For fixing the currency format I used something like this:

                     

                    /**  * BC displays swiss francs CHF without trailing space. fix this.  */

                    var correctCurrencySymbol = function(elems) {

                    jQuery(elems).each(function (index, item) {

                    jQuery(item).html(jQuery(item).html().replace(/CHF/ig, "CHF "));

                    });

                    };

                     

                    Where elems is  an array of nodes holding possible currency values:

                     

                    correctCurrencySymbol(jQuery("div.myPrice a:contains('CHF'), div.price a:contains('CHF'), table.cartSummaryTable td.cartSummaryItem:contains('CHF')"))

                     

                    Likewise to override system messages not configurable elsewhere I use Jquery again:

                     

                    jQuery(".productItemNotFound").text("Einige Sachen in der Pipeline...")

                     

                    …finds the DOM-Element where the no-items-found-message is displayed and sets the text accordingly.

                     

                    Note:

                     

                    AFAIK there is no way to correct these messages before they a rendered - since we do not (and nvere will?) have access to the server-side of things. The only way to face this problem is to correct the string AFTER the page has loaded. Then we have to problem that we need to parse the whole page after every page load. This is why I included a hidden field to see on what page I am and only correct the parts needed for that page.

                     

                    Also note, that this soultion might not work in the future, when BC decides to change the output or the use of some variables. But hopefully we get full i18n support by then.

                     

                    To apply the solution provided you need a basic understanding of javascript or a framework like jQuery. jQuery certainly is a good choice here, since it handles DOM-Manipulation very well.

                     

                    If you’re not familiar with jQuery please google some of the resources on how to use it.

                     

                    Pointers to the solution.  •     In each oft he BC layout-pages you  use, call your custom script •     In a $(document).ready() handler. •     Within this handler call the localizeSystemMessages function I provided •     and any other functions that help to override the messages as shown above

                     

                    Hope this points you in the right direction.

                     

                    Good luck!

                     

                    Andy

                    • 7. Re: Translation of messages which can't be controlled in the online-shop.js.
                      Frank Grootaarts Community Member

                      Hello Andy,

                       

                      Thanks for your contribution on this discussion! I have to say that my knowlegde about javascript and Jquery is very limited. But i will dive into this because i have to get those things fixed now. When BC adds other languages in the Culture settings of the domain-names the problem will be solved for non-english websites. I hope they will add this soon. But in the meantime i have to solve it somehow else. Your answer is very helpfull on this.

                       

                      May i also ask which code you used to translate the "shopping cart is empty" text in the {module_shoppingcartsummary,vertical,}?

                       

                      Thank you very Much,

                       

                      Frank

                       

                      And to make it more complete:

                       

                      12. "remove"  In the {tag_productremovelink}

                      • 8. Re: Translation of messages which can't be controlled in the online-shop.js.
                        Sergio Castagna Community Member

                        Hi Frank,

                        I am on the same opinion than you. I think that the multi language web site has to be improved. Actually, I am using two different domains names (one for english and one for french) and it solve my problem regarding the module language, except at the level of the shopping cart and the buy page, which I had to put the two languages on the page.

                         

                        This configuration give me also a problem with my payment gateway for an invalid certificate when the customer is redirect back to BC, which make the site unsecure for a customer perspective.

                         

                        I have tried to solve this point with the support since several weeks, unsuccessfull for the time being (if someone has an idea, do not hesitate to let me know :-) )

                         

                        We really need the capacity to build e-commerce in multi language as in all countries, online shop will have to cope with this type of difficulties.

                         

                        Have a great day,

                         

                        Sergio

                        • 9. Re: Translation of messages which can't be controlled in the online-shop.js.
                          Mike Connolly Community Member

                          Hi Frank,

                           

                          Good starting place to learn jQuery would be W3Schools http://w3schools.com/jquery/default.asp

                           

                          Regards

                           

                          Mike

                          • 10. Re: Translation of messages which can't be controlled in the online-shop.js.
                            DesignEffects Community Member

                            Hello Frank,

                             

                            Good question/suggestion! I am on the same opinion than you. I think that the multi language web site has to be improved.

                             

                            Regards,

                             

                            Willem

                            (The Netherlands)

                            • 11. Re: Translation of messages which can't be controlled in the online-shop.js.
                              Frank Grootaarts Community Member

                              Hello there,

                               

                              So far we have 12 known rendered sytem-strings which have to be translated. And here is number 13:

                               

                              13 "Tell a Friend" in the: {tag_tellafriend}

                               

                              I have also find a solution to translate the "shopping cart is empty" text which is rendered in the {module_shoppingcartsummary,vertical}

                               

                              Although i have still not enough knowledge about javascript/jquery  i did some googling and i found a script which does the job. here it is:

                               

                              <!--This script translates "Shopping cart is empty" in something else.-->

                                      <script type="text/javascript">

                               

                                        $.fn.replaceText = function( search, replace, text_only ) { 

                                return this.each(function(){ 

                                  var node = this.firstChild, 

                                    val, 

                                    new_val, 

                                    remove = []; 

                                  if ( node ) { 

                                    do { 

                                      if ( node.nodeType === 3 ) { 

                                        val = node.nodeValue; 

                                        new_val = val.replace( search, replace ); 

                                        if ( new_val !== val ) { 

                                          if ( !text_only && /</.test( new_val ) ) { 

                                            $(node).before( new_val ); 

                                            remove.push( node ); 

                                          } else { 

                                            node.nodeValue = new_val; 

                                          } 

                                        } 

                                      } 

                                    } while ( node = node.nextSibling ); 

                                  } 

                                  remove.length && $(remove).remove(); 

                                }); 

                              }; 

                               

                               

                              $(".cartSummaryItem").replaceText( "Shopping cart is empty.", "Your own translation." );

                               

                               

                              </script>

                               

                              I have put this code just before the </body> tag in my templates. I tested it and it works.

                               

                              Feel free to add or give advice about this script. Maybe someone can tell us if we can use this to translate more system-strings (maybe with a tweak?).

                               

                              Thanks!

                              • 12. Re: Translation of messages which can't be controlled in the online-shop.js.
                                Mike Connolly Community Member

                                Hi Frank,

                                 

                                At a glance that looks like a pretty useful jQuery function which you can re-use for anything you need to replace.

                                 

                                The first part of the code sets up the function, the last line does the work:

                                 

                                $(".cartSummaryItem").replaceText( "Shopping cart is empty.", "Your own translation." );

                                 

                                 

                                Providing you've specified the function part earlier, you can re-use the line above "over and over" to find and replace anything.

                                 

                                You need to replace ".cartSummaryItem" with a unique CSS style identifier to find the relevant page part to search.

                                 

                                Then change "Shopping cart is empty." with what you wish to find, and finally add your translation.

                                 

                                 

                                You'd need to be careful if your text your finding or replacing contains a qoute ("), this would break the call.

                                e.g.  $(".myClass").replaceText( "They said, "Hello" ", "Your own translation." );

                                 

                                In this case you could put a double quote, like:

                                e.g. $(".myClass").replaceText( "They said, ""Hello"" ", "Your own translation." );

                                 

                                Or use single quotes ( ' ) like:

                                e.g. $(".myClass").replaceText( 'They said, "Hello" ', 'Your own translation.' );

                                 

                                Hope this makes sense.

                                 

                                Regards

                                 

                                Mike

                                • 13. Re: Translation of messages which can't be controlled in the online-shop.js.
                                  shannesunonsen Community Member

                                  This is great, Frank - thanks a lot
                                  For now, my "shopping cart is empty" and "item(s)" strings are solved, but the "No one logged in" will not respond... and I still need to take a look at all the other strings, but I just wanted to complement you on your work


                                  /Shanne

                                  • 14. Re: Translation of messages which can't be controlled in the online-shop.js.
                                    shannesunonsen Community Member

                                    No. 14: " -- All catalogs -- " in {module_catalogueselect}

                                    • 15. Re: Translation of messages which can't be controlled in the online-shop.js.
                                      Frank Grootaarts Community Member

                                      No. 15: "Discount code applied but will not take effect until threshold reached." In the shopping_cart module template. Is this a message which maybe could be controlled in the online-shop.js?

                                      • 16. Re: Translation of messages which can't be controlled in the online-shop.js.
                                        WJBroer Community Member

                                        Hi Mario,

                                         

                                        You mention product management in this topic, did you talk to them lately? Do you have any idea when more languages will be supported in Business Catalyst?

                                         

                                        Because it would be really helpful to be able to customize all messages on a Business Catalyst site without all these workarounds.

                                         

                                        Thanks!

                                         

                                        Ruud