-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cfdfa08
commit 36cfef5
Showing
334 changed files
with
2,814 additions
and
255 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,3 +24,4 @@ vignettes/*.pdf | |
## Local locale for testing | ||
locale/ | ||
locale/* | ||
inst/doc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,27 @@ | ||
Package: shi18ny | ||
Title: Tools for shiny apps internationalization | ||
Version: 0.0.1 | ||
Authors@R: person("Juan Pablo", "Marin Diaz", email = "[email protected]", role = c("aut", "cre")) | ||
Description: Tools for shiny apps internationalization | ||
Version: 0.1.0 | ||
Authors@R: | ||
person(given = "Juan Pablo", | ||
family = "Marin Diaz", | ||
role = c("aut", "cre"), | ||
email = "[email protected]") | ||
Maintainer: Juan Pablo Marin Diaz <[email protected]> | ||
Description: Create shiny apps in multiples languages. You can include | ||
common words in multiple languages or provide your custom translations. | ||
URL: https://github.com/datasketch/shi18ny, https://shi18ny.datasketch.dev | ||
BugReports: https://github.com/datasketch/shi18ny/issues | ||
License: MIT + file LICENSE | ||
LazyData: true | ||
Depends: | ||
R (>= 3.0.0), | ||
yaml | ||
Imports: | ||
shiny (>= 0.11.1), | ||
shinyjs | ||
License: MIT | ||
LazyData: true | ||
RoxygenNote: 6.1.1 | ||
shiny, | ||
shinyjs, | ||
yaml | ||
Encoding: UTF-8 | ||
Suggests: | ||
knitr, | ||
rmarkdown | ||
VignetteBuilder: knitr | ||
RoxygenNote: 7.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
|
||
|
||
#' Add images to dropdown options | ||
#' | ||
#' This function works only with bootstrap for now | ||
#' | ||
#' @param inputId The input slot that will be used to access the value. | ||
#' @param choices List of values to select from, when named the names are | ||
#' appended to the right of the image. | ||
#' @param images List of image location that can be put in a src attribute. | ||
#' @param selected Selected image, defaults to first one. | ||
#' @param placeholder HTML to render as placeholder, overrides selected param. | ||
#' @param width width in of input. | ||
#' | ||
#' Borrowed from the package shinyinvoer | ||
#' | ||
selectImageInput <- function(inputId, label, choices, images = NULL, | ||
selected = 1, | ||
placeholder = NULL, | ||
width = 120) { | ||
|
||
shiny::addResourcePath( | ||
prefix='selectImage', | ||
directoryPath=system.file("lib/selectImage", | ||
package='shinyinvoer') | ||
) | ||
|
||
choices_list <- lapply(seq_along(choices), function(x){ | ||
list(id = choices[x], | ||
image = images[x], | ||
label = ifelse(is.null(names(choices[x])), 0, names(choices[x])) | ||
) | ||
}) | ||
|
||
if(is.numeric(selected)) | ||
selected <- choices[selected] | ||
if(is.null(placeholder)){ | ||
x <- choices_list[[selected]] | ||
placeholder <- shiny::div(class = "selectImage", shiny::img(src=x$image), x$label) | ||
} | ||
|
||
input <- jsonlite::toJSON(choices_list, auto_unbox = TRUE) | ||
|
||
shiny::div( | ||
`data-options` = htmltools::HTML(input), | ||
`data-selected` = selected, | ||
id = inputId, | ||
class = "dropdown", | ||
style = paste0('width:', width, 'px;'), | ||
label, | ||
shiny::tagList( | ||
shiny::singleton( | ||
shiny::tags$head( | ||
shiny::tags$link(rel = 'stylesheet', | ||
type = 'text/css', | ||
href = 'selectImage/selectImage.css'), | ||
shiny::tags$script(src = 'selectImage/selectImage-bindings.js') | ||
) | ||
) | ||
), | ||
) | ||
} | ||
|
||
#' Update select image input | ||
#' | ||
#' @param session Shiny session | ||
#' @param inputId The input slot that will be used to access the value. | ||
#' @param choices List of values to select from, when named the names are | ||
#' appended to the right of the image. | ||
#' @param images List of image location that can be put in a src attribute. | ||
#' @param selected Selected image, defaults to first one. | ||
#' @param placeholder HTML to render as placeholder, overrides selected param. | ||
#' @param width width in of input. | ||
#' | ||
#' @export | ||
updateSelectImageInput <- function(session, inputId, label = NULL, choices = NULL, | ||
images = NULL, selected = NULL) { | ||
message <- dropNulls( | ||
list( | ||
label = label, | ||
choices = choices, | ||
images = images, | ||
selected = selected) | ||
) | ||
session$sendInputMessage(inputId, message) | ||
} | ||
|
||
|
||
# copied from shiny since it's not exported | ||
dropNulls <- function(x) { | ||
x[!vapply(x, is.null, FUN.VALUE=logical(1))] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
--- | ||
output: github_document | ||
--- | ||
|
||
<!-- README.md is generated from README.Rmd. Please edit that file --> | ||
|
||
```{r, include = FALSE} | ||
knitr::opts_chunk$set( | ||
collapse = TRUE, | ||
comment = "#>", | ||
fig.path = "man/figures/README-", | ||
out.width = "100%" | ||
) | ||
``` | ||
|
||
# shi18ny | ||
|
||
<!-- badges: start --> | ||
<!-- badges: end --> | ||
|
||
Shiny apps internationalization: same app, multiple languages. | ||
|
||
Check the full documentation at http://shi18ny.datasketch.dev | ||
|
||
|
||
## Installation | ||
|
||
You can install the development version from [GitHub](https://github.com/) with: | ||
|
||
``` r | ||
# install.packages("devtools") | ||
devtools::install_github("datasketch/shi18ny") | ||
``` | ||
## Your first multilanguage shiny app | ||
|
||
This is a basic example which shows you how to solve a common problem: | ||
|
||
```{r example} | ||
#library(shi18ny) | ||
## basic example code | ||
``` | ||
|
||
|
||
## Configuration | ||
|
||
|
||
|
||
## Add custom languages | ||
|
||
Explore more examples. | ||
|
||
|
||
## Roadmap | ||
|
||
- Support RTL languages properly | ||
- Add locale formatting for dates | ||
- ... | ||
|
||
|
||
## FAQ | ||
|
||
### My language is not yet supported, what can I do to help? | ||
|
||
File an issue and make a pull request following the instructions in the vignette. | ||
|
||
|
||
|
||
# Acknowledgements | ||
|
||
## Flags from | ||
|
||
Country Flags taken from https://github.com/hjnilsson/country-flags | ||
Catalonia flag from [wikipedia](https://meta.wikimedia.org/wiki/File:Flag_of_Catalonia.svg) | ||
|
||
|
||
|
||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
library(tidyverse) | ||
|
||
# PNG flags from | ||
# https://github.com/gosquared/flags | ||
|
||
langs <- availableLangs() | ||
images <- list.files("data-raw/32", full.names = TRUE) | ||
|
||
langs_country <- tribble( | ||
~lang, ~country, | ||
"ar","SA", | ||
"da","DK", | ||
"de","DE", | ||
"en","US", | ||
"es","ES", | ||
"fr","FR", | ||
"he","GR", | ||
"hi","IN", | ||
"it","IT", | ||
"pt","PT", | ||
"pt_BR","BR", | ||
"ru","RU", | ||
"sv","SE", | ||
"zh_CN","CN" | ||
) | ||
# Manually add Catalonia and fallbacks (e.g. Colombia) | ||
|
||
all(langs_country$country %in% basename(file_path_sans_ext(images))) | ||
|
||
lapply(transpose(langs_country), function(x){ | ||
file.copy(paste0("data-raw/32/",x$country,".png"), | ||
paste0("inst/flags/png/",x$lang,".png")) | ||
}) | ||
|
||
|
||
### Another attempt resizing SVGs directly. | ||
|
||
# library(magick) | ||
# images <- list.files(system.file("flags","svg", package = "shi18ny"), full.names = TRUE) | ||
# | ||
# lapply(images, function(image){ | ||
# img <- image_read(image) %>% image_resize("32") | ||
# path <- gsub("\\/svg","\\/png32",image) | ||
# path <- gsub("\\.svg","\\.png",path) | ||
# image_write(img, path, format = "png") | ||
# }) | ||
|
||
|
||
|
||
#usethis::use_data("DATASET") |
Oops, something went wrong.