2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
5 Desc: Tell locale that the preferences have been changed.
10 #include <exec/types.h>
11 #include <proto/exec.h>
12 #include <proto/dos.h>
13 #include <proto/utility.h>
15 #include <utility/utility.h>
16 #include "locale_intern.h"
18 static const char *langlist
[] =
34 /*****i***********************************************************************
37 #include <proto/locale.h>
39 AROS_LH1(struct Locale
*, LocalePrefsUpdate
,
42 AROS_LHA(struct Locale
*, locale
, A0
),
45 struct LocaleBase
*, LocaleBase
, 28, Locale
)
48 This internal function is called by the IPrefs program to
49 notify the locale.library that the system preferences have
53 locale - A pointer to the new locale preferences.
56 The address of the old locale preferences data. This should
57 have CloseLocale() called upon it.
60 You can safely call CloseLocale() on the new Locale as this
61 function will ensure that the Locale will not be freed until
62 PrefsUpdate() is called again.
72 *****************************************************************************/
76 struct IntLocale
*old
= NULL
;
77 STRPTR language
, dotptr
;
82 /* Lock the locale structures */
83 ObtainSemaphore(&IntLB(LocaleBase
)->lb_LocaleLock
);
85 /* Remote the old locale, and decrease its user count. */
86 old
= IntLB(LocaleBase
)->lb_CurrentLocale
;
89 /* Update the count and install the new locale. */
90 IntL(locale
)->il_Count
++;
91 IntLB(LocaleBase
)->lb_CurrentLocale
= IntL(locale
);
92 ReleaseSemaphore(&IntLB(LocaleBase
)->lb_LocaleLock
);
94 /* Let's be mean to save some hassle */
95 language
= locale
->loc_LanguageName
;
96 if ((dotptr
= strchr(language
, '.')))
99 /* Update ENV:Language */
100 SetVar("Language", language
, -1, LV_VAR
| GVF_GLOBAL_ONLY
);
102 /* Update UtilityBase->ub_Language */
103 while (langlist
[index
] != NULL
)
105 if (strcmp(language
, langlist
[index
++]) == 0)
107 /* Check for american-english */
108 if (index
== 1 && locale
->loc_MeasuringSystem
== MS_AMERICAN
)
111 UtilityBase
->ub_Language
= index
+1;
116 if (dotptr
) *dotptr
= '.';
118 return (struct Locale
*)old
;