Skip to content

Make Your 'golem' App Shine

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md
Notifications You must be signed in to change notification settings

ThinkR-open/gemstones

Repository files navigation

gemstones

R-CMD-check Lifecycle: experimental

Make your {golem} based apps more beautiful with {gemstones}.

Installation

You can install the development version of {gemstones} like so:

remotes::install_github("thinkr-open/gemstones")

About

You’re reading the doc about version : 0.0.0.9001

This README has been compiled on the

Sys.time()
#> [1] "2023-03-27 13:26:46 CEST"

Here are the test & coverage results :

devtools::check(quiet = TRUE)
#> ℹ Loading gemstones
#> ── R CMD check results ─────────────────────────────── gemstones 0.0.0.9001 ────
#> Duration: 7.7s
#> 
#> 0 errors ✔ | 0 warnings ✔ | 0 notes ✔
covr::package_coverage()
#> gemstones Coverage: 48.04%
#> R/use_notifyjs.R: 0.00%
#> R/use_jqueryi18next.R: 77.78%

How it works

The goal of {gemstones} is to allow you to add some JavaScript libraries to your {golem} based app.

{gemstones} will automate the download and the linking of some JS libraries, but it’s important to understand that {gemstones} is not providing a full wrapper or widget for these libraries. You’ll still have to code some elements to make it work.

Note also that the functions in this package are not intended to work outside of a {golem} based app.

Notifyjs

Skeleton for Notifyjs can be added with gemstones::use_notifyjs().

This function will do the following:

  • Download notifyjs from the website.
  • Add a notifyjs_handlers.js file, which are shiny custom message handlesr
  • Add fct_notifyjs.R, which contains notify_success(), notify_warning(), & notify_error().
  • Add tes.

How to use notifyjs

This JS plugin provides notifications that can be sent and customize via the R functions defined in fct_notifyjs.R

jquery-i18next

Skeleton for jquery-i18next can be added with gemstones::use_jqueryi18next().

This function will do the following:

  • Download i18next & jquery-i18next from a CDN.
  • Add a i18n_locales.json file, which you can use to add your translation.
  • Add a i18n_shiny.js file, which will load the lib & data when your shiny app launched.
  • Add a i18n_handlers.js file, which are shiny custom message handlesr
  • Add fct_i18n.R, which contains with_i18n(), localize(), change_language() & get_language().
  • Add test for with_i18n().

How to use jquery-i18next

This JS plugin provides client-side translation of the UI elements.

To define a translation, you need to follow this pattern:

gemstones::use_jqueryi18next()
# Add a i18n tag to your element
h1("Hello") |> with_i18n("main_title")
{
    "en": {
        "translation": {
            "main_title": "Hello World"
        }
    },
    "fr": {
        "translation": {
            "main_title": "Wesh la famille"
        }
    }
}

Then at app launch, this title will be translated.

To switch from one language to the other, you can use one of these two technics:

  • Run code in JavaScript:
//  Set the language
i18next.changeLanguage('fr')
// Localize
$("html").localize()
  • Run code in R:
change_language("fr")
localize("html")

Releases

No releases published

Packages

No packages published