@@ -33,6 +33,10 @@ SILE.languageSupport = {
3333 end
3434 local ftlresource = string.format (" i18n.%s" , language )
3535 SU .debug (" fluent" , " Loading FTL resource" , ftlresource , " into locale" , language )
36+ -- This needs to be set so that we load localizations into the right bundle,
37+ -- but this breaks the sync enabled by the hook in the document.language
38+ -- setting, so we want to set it back when we're done.
39+ local original_language = fluent :get_locale ()
3640 fluent :set_locale (language )
3741 local gotftl , ftl = pcall (require , ftlresource )
3842 if not gotftl then
@@ -46,6 +50,7 @@ SILE.languageSupport = {
4650 if type (lang ) == " table" and lang .init then
4751 lang .init ()
4852 end
53+ fluent :set_locale (original_language )
4954 end ,
5055}
5156
@@ -65,10 +70,11 @@ end, nil, nil, true)
6570SILE .registerCommand (" fluent" , function (options , content )
6671 local key = content [1 ]
6772 local locale = options .locale or SILE .settings :get (" document.language" )
73+ local original_locale = fluent :get_locale ()
74+ fluent :set_locale (locale )
6875 SU .debug (" fluent" , " Looking for" , key , " in" , locale )
6976 local entry
7077 if key then
71- fluent :set_locale (locale )
7278 entry = fluent :get_message (key )
7379 else
7480 SU .warn (" Fluent localization function called without passing a valid message id" )
@@ -83,12 +89,13 @@ SILE.registerCommand("fluent", function (options, content)
8389 if entry then
8490 message = entry :format (options )
8591 end
86- fluent :set_locale (locale )
8792 end
93+ fluent :set_locale (original_locale )
8894 SILE .processString ((" <sile>%s</sile>" ):format (message ), " xml" )
8995end , nil , nil , true )
9096
9197SILE .registerCommand (" ftl" , function (options , content )
98+ local original_locale = fluent :get_locale ()
9299 local locale = options .locale or SILE .settings :get (" document.language" )
93100 SU .debug (" fluent" , " Loading message(s) into locale" , locale )
94101 fluent :set_locale (locale )
@@ -98,6 +105,7 @@ SILE.registerCommand("ftl", function (options, content)
98105 local input = content [1 ]
99106 fluent :add_messages (input , locale )
100107 end
108+ fluent :set_locale (original_locale )
101109end , nil , nil , true )
102110
103111require (" languages.unicode" )
0 commit comments