File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed
bindings/src/main/scala/chrome/i18n Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,9 @@ import scala.concurrent.{Future, Promise}
44import scala .scalajs .js
55import chrome .utils .ErrorHandling ._
66
7+ import js .JSConverters ._
8+ import scala .scalajs .js .|
9+
710object I18N {
811
912 def getAcceptLanguages : Future [js.Array [String ]] = {
@@ -14,9 +17,14 @@ object I18N {
1417 promise.future
1518 }
1619
17- def getMessage (messageName : String ,
18- substitutions : String * ): js.UndefOr [String ] =
19- bindings.I18N .getMessage(messageName, substitutions : _* )
20+ def getMessage (messageName : String , substitutions : String * ): js.UndefOr [String ] = {
21+ if (substitutions.isEmpty) {
22+ bindings.I18N .getMessage(messageName)
23+ } else {
24+ val jsArraySubstitutions = substitutions.toJSArray.asInstanceOf [String | js.Array [String ]]
25+ bindings.I18N .getMessage(messageName, Some (jsArraySubstitutions).orUndefined)
26+ }
27+ }
2028
2129 def getUILanguage : String = bindings.I18N .getUILanguage()
2230
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package chrome.i18n.bindings
22
33import scala .scalajs .js
44import scala .scalajs .js .annotation .JSGlobal
5+ import scala .scalajs .js .|
56
67@ js.native
78@ JSGlobal (" chrome.i18n" )
@@ -11,7 +12,7 @@ object I18N extends js.Object {
1112 js.native
1213
1314 def getMessage (messageName : String ,
14- substitutions : String * ): js.UndefOr [String ] = js.native
15+ substitutions : js. UndefOr [ String | js. Array [ String ]] = js.undefined ): js.UndefOr [String ] = js.native
1516
1617 def getUILanguage (): String = js.native
1718
You can’t perform that action at this time.
0 commit comments