Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

English locales are refused by config() #1686

Copy link
Copy link
Closed
@salim-b

Description

@salim-b
Issue body actions

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:

https://github.com/ropensci/plotly/blob/c47c1f957f1783d6212842463b0722c9473093b7/R/layout.R#L136-L142

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.