Switching languages programmatically?

AlxAlx Member Posts: 38
Hello!

Does anyone know if it is possible to change the UserLanguage IN a report? The thing is, I have a report all set up with CaptionML in Greek and English. What I want to do is check the Country Code of the customer and print the Greek captions for Greek customers and the English captions for all the others. Is it possible to write code for this or should I tell my customer to manually switch languages?

Thanx,

Alx

Comments

  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    Isn't this standard Navision ?

    CurrReport.LANGUAGE

    Look in Report 206 Invoice

    Succes
  • AlxAlx Member Posts: 38
    Yes it is, you are right! :oops:

    Thanks for the quick response!

    Alx
  • Michael_SchumacherMichael_Schumacher Member Posts: 81
    Hi there,

    in this context I have another question:

    imagine a customer in poland, on customer card you switch his language to polish. for your Items you have extended texts in polish
    they will appear in sales lines, as far as that ok.

    imagine further you have a german localisation of navision.

    as far as you didn't translate all the fields in the order confirmation report
    there will be printed german labels instead of the english ones.

    My boss says that he once had seen a table where you can put a setting
    which language is the default when desired isn't available.
    But unfortunately he can't find it again, neither can I.

    Has anyone an idea what we are looking for?
    regards,
    Michael Schumacher

    oh, what day is it? Backup day. OK, let's dump all data to /dev/nul ;-)
  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    As far as I know the languages are linked indeed.

    Default is the current language, then comes the related langage, then english (ENU) then, if no enu is present the first language layer and if no langages are in the database, then the fieldname.

    Example

    Language = NLB (Dutch Belgium)
    If not present = NLD (Dutch)
    if not present = ENU
    if not present = fieldname.

    I don't know if these dependences can be set up somewhere.
  • Timo_LässerTimo_Lässer Member Posts: 481
    1. You set up a "Navision Language Code" (e. g. ENG) to the customer.
    2. In the table "Languages" (Table 9), you can set up, which Windows Language should be used, if you use ENG.
    Normally, you would use 2057, but you also could define any other (also non-english) Windows language.
    3. Now, if you have defined 2057 for ENG, but your report does not support this, it looks in the table "Windows Language" what is the Primary Language ID and will find 1033.

    You cannot change anything in the table "windows language" because it is a virtual table.
    Timo Lässer
    Microsoft Dynamics NAV Developer since 1997
    MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    Thanks Timo!

    PS. Langages = table 8, form 9 :D
  • Michael_SchumacherMichael_Schumacher Member Posts: 81
    That's not that, what I wanted:

    I want to give the correct language codes to customers, so that they can take the correkt item extended text.
    But in reports there normally only should be english and german for the fieldnames and Textvariables, besides a customer wants to have the work to translate all fields and Variables ;-).

    But there should be a setting that english will be used as fallback language instead of german, when no translation in the correct language exists.
    The Working language in Navision to the navision user still should be german!

    so if a language is selected on customer card which is not a german language, english should be default....
    I don't know how to explain it better in english, because I'm not english ;-)
    regards,
    Michael Schumacher

    oh, what day is it? Backup day. OK, let's dump all data to /dev/nul ;-)
  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    That's not that, what I wanted:

    I was affraid of that but I hoped my post gave you an 'Aha-erlebnis' :D
  • Michael_SchumacherMichael_Schumacher Member Posts: 81
    That's not that, what I wanted:

    I was affraid of that but I hoped my post gave you an 'Aha-erlebnis' :D
    No, not really ;-)

    seems more than "auweia" :mrgreen:
    regards,
    Michael Schumacher

    oh, what day is it? Backup day. OK, let's dump all data to /dev/nul ;-)
  • Timo_LässerTimo_Lässer Member Posts: 481
    I hope, I understand correctly:
    - In Sales Order, you will get the polish extended texts due to the language code PL.
    - In Report, you will print the labels in english because there is no polish text layer

    The solution is what I wrote:
    Open the form 9 "Languages",
    find the record for polish (e. g. "PL")
    set the "Windows Language" to 1033

    This will not affect the language of the whole Navision client, only the current language of the report at runtime.
    Timo Lässer
    Microsoft Dynamics NAV Developer since 1997
    MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
  • Michael_SchumacherMichael_Schumacher Member Posts: 81
    Open the form 9 "Languages",
    find the record for polish (e. g. "PL")
    set the "Windows Language" to 1033

    This will not affect the language of the whole Navision client, only the current language of the report at runtime.

    Hmmmm, ok so for reports there is always used the windows language?
    I'll give it a try.....

    OK, this works, as long as there are no translations in the report wanted...
    but if you have some words translated to polish this will still be printed in english :-(

    So, if noone else has got an idea we (resp. our customers, who sell to poland) have to live with it
    regards,
    Michael Schumacher

    oh, what day is it? Backup day. OK, let's dump all data to /dev/nul ;-)
  • Timo_LässerTimo_Lässer Member Posts: 481
    Open the form 9 "Languages",
    find the record for polish (e. g. "PL")
    set the "Windows Language" to 1033

    [...]
    but if you have some words translated to polish this will still be printed in english :-(
    [...]
    If you have set up the Windows Language 1033 for Language Code "PL", the report will be switched to "English (US)" and ignores any polish captions in the controls.
    See as example the report 204, dataitem "Sales Header":
    Sales Header - OnAfterGetRecord()
    CurrReport.LANGUAGE := Language.GetLanguageID("Language Code");
    
    Timo Lässer
    Microsoft Dynamics NAV Developer since 1997
    MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    This still does not explain why, also on forms in a belgian database the language first is swiched from NLB to NLD and then to ENU.

    This must be stored in Navision internaly I think. :D

    This goes also for

    FRB-FRA-ENU

    and I think also

    DES-DEU-ENU

    ??????
  • Timo_LässerTimo_Lässer Member Posts: 481
    Yes, on forms, Navision works as you mentioned.
    What I wrote is only valid for Reports which have the code line as in report 204, otherwise the report will be executed in the application language.
    Timo Lässer
    Microsoft Dynamics NAV Developer since 1997
    MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
Sign In or Register to comment.