This discussion is archived
1 2 3 4 Previous Next 49 Replies Latest reply: Apr 4, 2013 7:36 AM by 983342 RSS

How to do the translation of alert messages from javascript

983342 Newbie
Currently Being Moderated
Hi,

I am working on translation of a application, when exporting the pages .xlf file it doesn't contain the javascript alert messages

and also if we are having any static Select List of Radio Button, those Static words are also not exporting in the xlf file.

How to do the conversion of above?

Ani
  • 1. Re: How to do the translation of alert messages from javascript
    peter_raganitsch Oracle ACE Director
    Currently Being Moderated
    Hi Ani,

    Static LOVs that are defined on Item Level cannot be translated. But if you convert them to Shared Component LOVs they can be translated.

    For Text Strings in Javascript i recommend to use Page Item Substitutions (&P123_WHATEVER_TEXT.).

    brgds,
    Peter
  • 2. Re: How to do the translation of alert messages from javascript
    Arie Geller Guru
    Currently Being Moderated
    Hello,

    I have some comments, on top of Peter reply.

    >> Static LOVs that are defined on Item Level cannot be translated. But if you convert them to Shared Component LOVs they can be translated.

    With Static LOVs defined as Shared Component, only the display part is included in the XLIFF file, and as such is translatable. If you need to also translate the returned value (e.g., in case the returned value is a string and not a number), you can't use Static LOVs. In the following there is a suggestion how to workaround this issue - Re: how to translate static and dynamic LOV's

    >> For Text Strings in Javascript i recommend to use Page Item Substitutions (&P123_WHATEVER_TEXT.).

    This is valid only if you are using an inline JavaScript code. You can't use Substitution String notation with external JavaScript files. In this case you need to manually translate the alert messages and you can't use the APEX translation mechanism.

    Regards,
    Arie.
  • 3. Re: How to do the translation of alert messages from javascript
    peter_raganitsch Oracle ACE Director
    Currently Being Moderated
    Hi Arie,

    nice one, didn't know that the return-value isn't in the xliff. But as I think about it, i'm certain that return values shouldn't be language-specific as that is meant to be an ID or something alike.

    Thanks for clarifying the Item-Substitution to work in inline-JS code only, that is important to mention here. As an Addition to that comment we could say that language-specific messages in external JS-Functions could be passed as argument.

    brgds,
    Peter
  • 4. Re: How to do the translation of alert messages from javascript
    983342 Newbie
    Currently Being Moderated
    Hi Arie

    Hello Peter

    Thanks both of you for your replies.

    I tried above methods, for Lov it works fine, I created Lov in shared components and it does translated.

    but for the javascript alerts, I was not able to do the above method.

    I tried another method for that using Ajax. Here are the steps:

    1. Created a dynamic translation of the message.
    2. Created a application process, which do the conversion using apex_lang.lang
    3. Called the above process from my page, and passed the message, in return process returns the translated message.

    so, both the issues are resolved.

    I have one more doubt about the images.

    at some places in our application we are having some images with some texts, and those images are uploaded into WORKSPACE IMAGES.

    In the translated application Mapping, I can see a field for image directory path, but not able to find out how to replace the images.

    Do I need to upload the images in /i/ directory?
    if I do that also, how the image path is going to mapped?

    Please do help in this issue also.

    Thanks again
    Ani
  • 5. Re: How to do the translation of alert messages from javascript
    peter_raganitsch Oracle ACE Director
    Currently Being Moderated
    Hi Ani,

    not sure if you want to fire an AJAX Process to read a text-string. Why don't you set a JS-Variable (Array, whatever) when loading/creating the page. E.g. in the Page Header JS-Section.

    Anyways: Images are not part of the translation. It seems that Images are not supposed to have any language specific text, therefor you cannot translate those.

    brgds,
    Peter
  • 6. Re: How to do the translation of alert messages from javascript
    Arie Geller Guru
    Currently Being Moderated
    Hello Peter and Ani,

    Some comments on your last posts.

    >> … But as I think about it, i'm certain that return values shouldn't be language-specific as that is meant to be an ID or something alike.

    From my experience, static LOVs are often used with the same display and returned value, and the value saved is not necessarily a numeric ID or PK. I'm using static LOVs with values like Yes/No, Male/Female, True/False, Red/Yellow/Green, etc. In many cases, I prefer to save the real value and not a numeric representation of it. If you are working in a multi-language environment, some of these values need to be translated, and if you are using a Shared Component Static LOV, it can't be done. Of course, if your returned values are language indifferent, and all you need is to translate the UI, Peter's solution works perfectly.

    >> I tried another method for that using Ajax …

    I'll be more blunt than Peter. This is a bad solution.

    The only reason we are using JavaScript alert is to prevent the round trip to the server and back, and here you are, making the trip to the server, anyway. If you are willing to pay the price of calling the server, you should use the regular APEX (server side) validations. However, in many cases, this is indeed too costly, and using JavaScript is well deserved. In these cases, you should manually translate your string messages, as part of your JavaScript code.

    >> Images are not part of the translation. It seems that Images are not supposed to have any language specific text, therefor you cannot translate those.

    This is only partially true. In some cases the image includes a language dependent message. The APEX icons collection, for example, includes icons with English text like Edit, Delete or Go. You can use these icons, or generate your own, with APEX Buttons. If you are doing so, with multi-lingual translated application, these icons need to be translated. Of course, as we are dealing with graphic based files (and not textual files) we can't use the built-in APEX translation mechanism, and we need to use graphical editing tools.

    Another aspect of Images can emerge if you are working with languages that are written from Right-To-Left (e.g., Arabic and Hebrew). With these languages, you should also (vertically) reverse the orientation of the images.

    >> Do I need to upload the images in /i/ directory?

    The simple answer is yes. The APEX translation mechanism allows you to define a separate */images/* directory to any translated language you are using. If you need to "translate" many images, this is the preferred solution. Of course, in this case you need to define more alias(s) to your new /images/ directory(s), so you'll have other alias(s) than just /i/.

    Regards,
    Arie.
  • 7. Re: How to do the translation of alert messages from javascript
    peter_raganitsch Oracle ACE Director
    Currently Being Moderated
    Hi Arie,

    again thanks for your answer and the detailed explanation and correcting me on the images. I'm with you on all of these.

    There is just one thing i want to point out: if there are currently uses of LOV's which have same return and display value, that doesn't make it right.
    I have come across them as often as everyone of us, and still think this is a mis-use. A return value should have no language specific meaning.
    It doesn't need to be numeric, you still can store Y/N for Yes/No, but you don't change that with your display language (Y/N then is used for Yes/No, Ja/Nein, Oui/No, Si/No, Ne/Ochi...).

    brgds,
    Peter
  • 8. Re: How to do the translation of alert messages from javascript
    983342 Newbie
    Currently Being Moderated
    Hello Peter,

    thanks again

    I think you are talking about this:

    http://stackoverflow.com/questions/4717475/how-to-translate-into-other-languages-my-web-page

    by creating a array in javascript and use it to show the alerts.

    but for that I need the language code, and that is stored in the application item "FSP_LANGUAGE_PREFERENCE" and to read this items value, I have to call Application Process, which is again the same round trip to server.

    Is there any other way you are talking about?

    Hi Arie,

    Thans allot for your deep explaination,

    for Images, you said to create the alias to the /i/ directory, does it means to give the image directory path for each translation in the
    "Image Directory" field in Application Language Mapping?

    if its the same, how will I give path in the above field?, I tried giving path like /i/pt or /i/pt-br for different languages, but it doesn't work for me.

    and please check the above message of javascript alerts, am I right that for doing the manual translation also I have to call a application process, or please let me know what you are talking about.

    Regards
    Ani
  • 9. Re: How to do the translation of alert messages from javascript
    Arie Geller Guru
    Currently Being Moderated
    Hello Ani,

    >> am I right that for doing the manual translation also I have to call a application process, or please let me know what you are talking about.

    No, you don't have to use Application Process or waste a trip to the server. The server already knows the application language before it renders the page. So, you can use a Substitution String notation to assign the value of FSP_LANGUAGE_PREFERENCE to a JavaScript global variable, and use this variable in your JavaScript code:
    var app_language = '&FSP_LANGUAGE_PREFERENCE.';
    >> if its the same, how will I give path in the above field?

    The whole trick is that the directories containing the "translated" images are not the same. Each directory should include the images that match its translated language. On the local OS level you actually duplicate the original /images directory, and replace the original images with the translated ones, and all your own images. For each such a directory you need to define a different alias.

    Regards,
    Arie.
  • 10. Re: How to do the translation of alert messages from javascript
    983342 Newbie
    Currently Being Moderated
    Hi Arie,

    That alert message is working for me, thanks again for your unique explanation, but I have one more question on this.

    let's say I want to add a new language into my application, and if I used the above method,
    I have to go to each page where I have alert message and add new language's translation in the array, isn't this require a lot of work,
    because we are doing kind of hard coding here and client has specified that there should not be much work while adding a new language.
    is there any work around for this?

    Sorry, if I am irritating you, but these are the possibilities coming across when I am working on.

    And for the Image path, "creating a alias" means are you talking about thing mentioned in this post ?

    How to change /i/ reference in APEX installation

    editing the dads.conf and creating different aliases, and referring those aliases in the image directory of each translation application?

    Regards
    Ani
  • 11. Re: How to do the translation of alert messages from javascript
    983342 Newbie
    Currently Being Moderated
    Hi Arie,

    Waiting for the reply.

    Please let me know what should be the best solution for the above.

    Regards
    Ani
  • 12. Re: How to do the translation of alert messages from javascript
    Arie Geller Guru
    Currently Being Moderated
    Hello Ani,

    I probably missed your post yesterday.

    I'm out of the office now, so I'll try to give you a detailed response later today.

    Regards,
    Arie.
  • 13. Re: How to do the translation of alert messages from javascript
    983342 Newbie
    Currently Being Moderated
    Ok, waiting for that

    Thanks
    Ani
  • 14. Re: How to do the translation of alert messages from javascript
    Arie Geller Guru
    Currently Being Moderated
    Hello Ani,

    >> I have to go to each page where I have alert message and add new language's translation in the array

    You are correct, and this is why I'm trying to refrain from using inline JavaScript, and I'm trying to concentrate it into an external file. With translated messages I'm using something similar to the following:
    switch (app_language){
      case 'en':
        alert('This is an English message');
        break;
      case 'fr':
        alert('Il s'agit d'un message en français')
        break;
    }
    >> client has specified that there should not be much work while adding a new language …

    Adding a new translated language is always a lot of work, even if you are using the APEX translation mechanism. I agree that it is easier to send an XLIFF file to the translator, and he/she can translate it quite easy without being an APEX developer. I'm afraid that with JavaScript it's a bit more complicated, but using an external file, all the messages that need to be translated can be found in a single location.

    >> And for the Image path, "creating a alias" means are you talking about thing mentioned in this post ?

    Exactly.

    Regards,
    Arie.
1 2 3 4 Previous Next

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points