Closed
Description
When trying to set a plot's locale to one of "en"
, "en-US"
or "en-GB"
, an error is thrown. But according to the documentation, at least "en"
and "en-US"
should be valid locales!
I know that English is the default locale. But right now changing a plot's locale from the default EN to something else is kind of a "one way road":
library(magrittr)
plotly::plot_ly(data = iris,
x = ~Sepal.Length,
y = ~Petal.Length) %>%
plotly::config(locale = "de-CH") %>%
plotly::config(locale = "en-US")
#> Error: Invalid locale: 'en-US'.
#>
#> Supported locales include: 'af', 'am', 'ar-dz', 'ar-eg', 'ar', 'az', 'bg', 'bs', 'ca', 'cs', 'cy', 'da', 'de-ch', 'de', 'el', 'eo', 'es-ar', 'es', 'es-pe', 'et', 'eu', 'fa', 'fi', 'fo', 'fr-ch', 'fr', 'gl', 'gu', 'he', 'hi-in', 'hr', 'hu', 'hy', 'id', 'is', 'it', 'ja', 'ka', 'km', 'ko', 'lt', 'lv', 'me', 'me-me', 'mk', 'ml', 'ms', 'mt', 'nl-be', 'nl', 'no', 'pa', 'pl', 'pt-br', 'rm', 'ro', 'ru', 'sk', 'sl', 'sq', 'sr', 'sr-sr', 'sv', 'sw', 'ta', 'th', 'tr', 'tt', 'uk', 'ur', 'vi', 'zh-cn', 'zh-hk', 'zh-tw'
Created on 2020-01-23 by the reprex package (v0.3.0)
This is because the available locales are determined by this code:
sub("\\.js$", "", list.files(system.file(plotly:::dependency_dir("plotlyjs", "locales"),
package = "plotly")))
#> [1] "af" "am" "ar-dz" "ar-eg" "ar" "az" "bg" "bs" "ca"
#> [10] "cs" "cy" "da" "de-ch" "de" "el" "eo" "es-ar" "es"
#> [19] "es-pe" "et" "eu" "fa" "fi" "fo" "fr-ch" "fr" "gl"
#> [28] "gu" "he" "hi-in" "hr" "hu" "hy" "id" "is" "it"
#> [37] "ja" "ka" "km" "ko" "lt" "lv" "me" "me-me" "mk"
#> [46] "ml" "ms" "mt" "nl-be" "nl" "no" "pa" "pl" "pt-br"
#> [55] "rm" "ro" "ru" "sk" "sl" "sq" "sr" "sr-sr" "sv"
#> [64] "sw" "ta" "th" "tr" "tt" "uk" "ur" "vi" "zh-cn"
#> [73] "zh-hk" "zh-tw"
Created on 2020-01-23 by the reprex package (v0.3.0)
Obviously, the English strings aren't defined in separate .js
files inside the directory htmlwidgets/lib/plotlyjs/locales
(relative to the plotly R package path). So I think there should be a proper exception added for EN locales in R/layout.R
:
Metadata
Metadata
Assignees
Labels
No labels