# install.packages("shiny.i18n")
library(shiny.i18n)
Mental Models
Mental Models
This is an experimental Quarto document to check whether we can use {shiny.i18n} with Quarto. The idea is simply to create a mock document and try using the package.
Occam’s Razor
When comparing hypotheses, the one with the fewest assumptions should be selected.
Description
Occam’s razor originally stated that entities should not be multiplied unnecessarily. In other words, don’t complicate things when you don’t need to. By shaving off unnecessary additions, the resulting explanation tends to be less ambiguous, easier to verify, and just plain simpler. Occam’s Razor is often mentioned when selecting a simple solution over a complex one. Note that this is a slightly stronger form than the principle intended–reality can be complex and there are cases where the simple solution is not correct.
Examples
- A sore throat during during the winter is probably the result of a cold even though the symptoms match a rare terminal disease on WebMD.
- The pyramids being built by humans has far less assumptions than the pyramids being built by aliens.
Let’s Try Translating
First, we will make a simple Translator object.
<- Translator$new(translation_json_path = "translations.json")
i18n
# Setting language to "pl" or Polish
# This should be defined in the file passed for 'translation_json_path'
$set_translation_language("pl")
i18n
i18n
<Translator>
Public:
at: function (keyword, api = "google")
automatic_translate: function (keyword, api = "google")
clone: function (deep = FALSE)
get_key_translation: function ()
get_languages: function ()
get_translations: function ()
initialize: function (translation_csvs_path = NULL, translation_json_path = NULL,
parse_date: function (date)
parse_number: function (number)
set_translation_language: function (transl_language)
t: function (keyword, session = shiny::getDefaultReactiveDomain())
translate: function (keyword, session = shiny::getDefaultReactiveDomain())
use_js: function ()
Private:
automatic: FALSE
js: FALSE
key_translation: key
languages: key en pl
mode: json
options: list
raw_translate: function (keyword, translation_language)
read_csv: function (translation_path, translation_csv_config, separator = ",")
read_json: function (translation_file, key_translation)
translation_language: pl
translations: data.frame
try_js_translate: function (keyword, translation)
Let’s use Inline Code with the format "r { code here }"
Modele psychologiczne
To jest eksperymentalny dokument Quarto, aby sprawdzić, czy możemy używać {shiny.i18n} z Quarto. Chodzi o to, aby po prostu stworzyć próbny dokument i spróbować użyć pakietu.
Brzytwa Ockhama
Porównując hipotezy, należy wybrać tę, która ma najmniej założeń.
Opis
Brzytwa Ockhama pierwotnie głosiła, że bytów nie należy mnożyć niepotrzebnie. Innymi słowy, nie komplikuj rzeczy, gdy nie musisz. Pozbywając się zbędnych dodatków, uzyskane wyjaśnienie wydaje się być mniej niejednoznaczne, łatwiejsze do zweryfikowania i po prostu prostsze. Brzytwa Ockhama jest często wymieniana przy wyborze prostego rozwiązania zamiast złożonego. Zauważ, że jest to nieco mocniejsza forma niż zamierzona zasada — rzeczywistość może być złożona i zdarzają się przypadki, w których proste rozwiązanie nie jest poprawne.
Przykłady
- Ból gardła w okresie zimowym jest prawdopodobnie wynikiem przeziębienia, mimo że objawy pasują do rzadkiej śmiertelnej choroby na WebMD.
- Piramidy budowane przez ludzi mają znacznie mniej założeń niż piramidy budowane przez kosmitów.
Conclusion
Using {shiny.i18n}
in Quarto has some caveats, but it works well.
The Good: We can use it as inline code as well as in chunks. The setup is exactly the same as with other projects
The-Not-So-Good: The Visual editor does not display the code results. We can only see it once we Render the document. But that is how it works for all R code, in general.