SiComponents Home Page SiComponents Forums
Here you will be able to get help and share your experience
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Language dispatcher=nil in FormCreate

 
Post new topic   Reply to topic    SiComponents Forums Forum Index -> TsiLang Components Suite
View previous topic :: View next topic  
Author Message
rodney232



Joined: 27 Mar 2017
Posts: 8

PostPosted: Thu Jul 06, 2017 2:20 am    Post subject: Language dispatcher=nil in FormCreate Reply with quote

I have a large Delphi project that supports 6 languages (English is default).
When the app is running, I can change to each language by setting the siLangDispatcher.ActiveLanguage appropriately.
I have the following code to set the appropriate active language in the main form's FormCreate method;
Code:

procedure TMainForm.FormCreate(Sender: TObject);
var
  vLanguageID: DWORD;

begin
  // set language (using only primary language identifier -> last byte)
  vLanguageID := GetUserDefaultLangID;
  case Byte(vLanguageID and $00FF) of
    LANG_ENGLISH:  siLangDispatcher.ActiveLanguage := 1;
    LANG_ARABIC:   siLangDispatcher.ActiveLanguage := 2;
    LANG_CHINESE:  siLangDispatcher.ActiveLanguage := 3;
    LANG_JAPANESE: siLangDispatcher.ActiveLanguage := 4;
    LANG_SPANISH:  siLangDispatcher.ActiveLanguage := 5;
    LANG_GERMAN:   siLangDispatcher.ActiveLanguage := 6;
    else
      siLangDispatcher.ActiveLanguage := 1;
    end;

  UpdateStrings;
  etc;


If I change regions (in Win10) to either English(Australia), Arabic(Saudi Arabia), Chinese(Simplified China) or German(Austria), the siLangDispatcher is not nil and the app starts up correctly showing the appropriate language.
If the region is set to either Japanese(Japan) or Spanish(Spain) then the siLangDispatcher is nil upon entry to the FormCreate and the app fails.
Any idea why this is happening?
I'm using Delphi Berlin Update 2 and Si components 7.5.6.1.
Back to top
View user's profile Send private message
isiticov
Site Admin


Joined: 21 Nov 2002
Posts: 2103

PostPosted: Sat Jul 08, 2017 6:59 pm    Post subject: Reply with quote

Hello,

Creation/initialization of dispatcher isn't related to application's running region. So I would suppose that there might be some code in your application that either prevents dispatcher from creation or destroys it somehow. If you can reproduce this problem on some simple sample project then please send it to us to test.
Thank you.
Back to top
View user's profile Send private message
Malcolm



Joined: 21 Jan 2003
Posts: 84
Location: Scotland

PostPosted: Mon Jul 10, 2017 3:07 pm    Post subject: Reply with quote

What value does GetUserDefaultLangID return for the failing Languages (before ANDing it)?

Are you able or willing to use System.SysUtils.TSysLocale ?

This works for me:
Code:

VAR
  ALanguage: Integer;
BEGIN
  // we only come here if the Active Language has not been set by user.
   ALanguage := SysLocale.PriLangID;
  CASE ALanguage OF
    LANG_CATALAN: Language := 15;
    LANG_CHINESE: Language := 13;
    LANG_DANISH:   Language := 9;
    LANG_GERMAN:  Language := 4;
    LANG_SPANISH: Language := 5;
    ....
  else
    Language := 1;
Back to top
View user's profile Send private message
rodney232



Joined: 27 Mar 2017
Posts: 8

PostPosted: Wed Jul 12, 2017 6:29 am    Post subject: Reply with quote

Thanks guys for the replies.
It turns out that I had inadvertently left some legacy language support code in an initialization section of one of my units. This code loaded the current language resource file which understandably clashed with the siLang components. All is good now!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    SiComponents Forums Forum Index -> TsiLang Components Suite All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by p h p B B  © 2001, 2005 p h p B B  Group