diff --git a/blogs/2022/5/14/bilingual-computing.md b/blogs/2022/5/14/bilingual-computing.md new file mode 100644 index 0000000..6b65f5c --- /dev/null +++ b/blogs/2022/5/14/bilingual-computing.md @@ -0,0 +1,91 @@ +# Bilingual Computing + +For the last few years, I've been trying to learn French, so that I can live in France. +I used to speak the language as a child when I lived in Paris, but that was nearly 20 years ago, so I've forgotten a lot of the it. +As well as langauges, I have a healthy interest in computing, online communication and free and open source software. +I'm adamant about independence in computing, and minimising my dependencies on services provided as products. + +In this post I'd like to talk about a little bit about a few additions and customisations I've made to my Linux environment to support learning and using multiple written languages. + +## Translation Commands + +The first and most obvious thing I wanted was a quick and dirty translator. +For me, this means being able to open a terminal, hammer in a command and a query, and get a result back. +I am not too concerned about the accuracy of the translator, or translating large amounts of text. +So long as it helps me most of the time with a word or phrase, and so long as it's quicker and easier than picking up my phone, it's good enough. + +I found [argos-translate](https://github.com/argosopentech/argos-translate), which provides open-source offline translation. +The user downloads translation dictionaries as packages and can then be used to translate strings of text, either individual words or entire phrases. + +Here's my script for translating a phrase in French to English, which I have saved as `en`: + +```bash +#!/usr/bin/env bash + +# fully expand arguments +phrase=$@ + +argos-translate --from-lang fr --to-lang en "$phrase" +``` + +Note that arguments passed into the script are expanded before being passed as a single string to the translation command. +That means that I am able to pass arguments without turning them into a literal string, which is nice. +Without wrapping it in quotes, however, characters such as apostrophes must be explicitly escaped. + +``` +en j\'aime bien les pingouins, ils s\'y connaissent en informatique +``` + +## Keyboard Layouts + +Now that I had a way to do quick translations, the next obvious limitation was my keyboard layout. +In casual conversation I've often copy-pasted, made do with using multiple characters ('e, e\`) to resemble diacritics, or just omitted them entirely and trusted the other party to understand. +This would be unacceptable for any longer-form writing, such as blog posts. + +Being a life-long QWERTY user, I was not enthralled by QWERTZ, AZERTY or any other standard European layout that would throw off my existing muscle memory. +Thankfully [QWERTY-fr](https://github.com/qwerty-fr/qwerty-fr) exists! +I haven't used an accented keyboard before, but I like how it is designed spatially. +It reminds me of vim's design, where the position of the key is more important than what is written upon it. + +After installing the additional layout, I wrote a script `kbfr` to enable it with `setxkbmap`. +I also included some other layout modifications which turn Caps Lock into Ctrl and Esc using `xcape`, and ensure they are run when I set the keyboard layout: + +``` +#!/usr/bin/env bash + +# while caps lock is held down, it applies a ctrl modifier to other keys +setxkbmap -option caps:ctrl_modifier + +# when caps lock is pressed or released, it acts as esc +xcape -e 'Caps_Lock=Escape' + +# enable the QWERTY-fr layout +setxkbmap -v -layout us_qwerty-fr +``` + +I also enabled the xkeyboard module for [polybar](https://github.com/polybar/polybar), so that I could see at a glance which layout I have enabled. + +## A Dictionary + +Finally, I wanted a more complete dictionary than my simple translator scripts. +This is mostly to help me learn the grammatical gender of words, which my translator scripts are only partially able to help with. +It's also good practice to figure out the meanings of words when I have only other words of the same language available to help! + +I found the open StarDict dictionary, which has a [command-line version, `sdvc`](https://wiki.archlinux.org/title/Sdcv). + +I installed a French dictionary for it with the AUR package `stardict-acadfr1935`, and since this is the only dictionary I have installed, usage is quite simple - I wrapped it in a `mot` script: + +``` +#!/usr/bin/env bash + +# get the meaning of a french word +sdcv -c -n $1 +``` + +This is something I'm not quite happy with yet, but it will do for now. +The dictionary could include more up-to-date definitions, and the output is often quite verbose. +The ArchWiki page does describe some suggested usages, which maybe I will look at in the future. + +--- + +Thanks to my Quebecois friend Vorty for helping me with my terrible language skills, both English and French. diff --git a/blogs/2022/5/14/linformatique-bilingue.md b/blogs/2022/5/14/linformatique-bilingue.md new file mode 100644 index 0000000..19d919a --- /dev/null +++ b/blogs/2022/5/14/linformatique-bilingue.md @@ -0,0 +1,99 @@ +# L'informatique bilingue + +Depuis quelques années maintenant, j'apprends le français afin d'aller habiter en France. +Je le parlais auparavant, j'ai vécu pendant un temps Paris quand j'étais jeune, mais cela date de presque 20 ans, j'ai donc perdu beaucoup de la langue. +En plus des langues, j'ai un très grand intérêt pout l'informatique, les communautés en ligne, et le logiciel libre et ouvert. +Je soutiens l'indépendance en informatique, et je veux minimiser le plus possible ma dépendance aux services fournit comme produits. + +Dans cette publication je voudrais parler un peu de quelques additions et modifcations que j'ai faire à mon environnement Linux, afin de faciliter l'apprentissage et l'utilisation de plusiers langues écrites. + +## Les commandes de traduction + +Le première chose évidente dont j'avais besoin était un traducteur rapide et facile d'accès. +Pour moi, cela signifie: ouvrir une terminal, entrer une commande et une requête, et obtenir un résultat immédiatement. +Je ne m'inquiète pas de la précision du traducteur, ni de supporter une grande quantité de texte. +Tant que ça m'aide avec un mot ou une phrase, et que c'est plus facile et rapide à utiliser que mon cellulaire, c'est suffisant. + +J'ai trouvé [argos-translate](https://github.com/argosopentech/argos-translate), une librarie hors ligne et open-source de traduction. +L'utilisateur télécharge des dictionnaires de traduction à partir son gestionnaire du paquet, lesquels peuvent ensuite à traduire des strings de texte, que ce soit des mots individuels ou des phrases entières. + +Voici mon scripte pour traduire une phrase en anglais en français, que j'appelé `fr`: + +~~~ bash + +#!/usr/bin/env bash + +# étendre pleinement les paramètres +phrase=$@ + +argos-translate --from-lang en --to-lang fr "$phrase" + +~~~ + +À noter que les paramètres passés dans le script sont étendus avant d'êtres passés comme un seul long string à la commande de traduction. + +Cela signifie que je peux passer des paramètres sans avoir à les convertir en string litérals, ce que est bien. +En ne l'entourant pas de guillements (`"`), certains caractères, comme l'apostrophe (`'`), soivent être explicitement échappes. + +``` +fr you shouldn\'t let your dog drive the car +``` + +## Dispositions du clavier + +Maintenant que j'ai une méthode pour rapidement obtenir des traductions, ma limitation suivante était mon clavier. +Dans mes conversations occasionelles, j'ai copié et collé, j'ai utilisé plusiers caractères ('e, e\`) pour ressembler aux diacritiques, ou je les ai simplement omis enspérant que mon interlocuteur comprendrait. +Ces façons sont inacceptables pour l'écrivement des publications plus longues, pour exemple cette un. + +Toute ma via j'ai utilisé QWERTY, j'aimais pas l'idée d'utiliser QWERTZ ou AZERTY, ou d'autres configurations standards européennes qui confondrait ma mémoire musculaire. +Heureusement, [QWERTY-fr](https://github.com/qwerty-fr/qwerty-fr) existe! +Je n'avais jamais utilisé un clavier supportant des accents ou diacritiques avant, mais j'aime comment c'est designé spatialement. +Ça me rappelle les layouts de Vim, où la positions des touches est plus important que sa légende. + +Après avoir installé la configuration additionnelle, j'ecrit un script `kbfr` pour l'activer avec `setxkbmap`. +J'ai aussi inclus d'autres modifications qui transforment Caps Lock en Ctrl et Esc en utilisant `xcape`, et s'assure qu'elles soient exécuté quand je change de configuration de clavier. + +``` +#!/usr/bin/env bash + +# pendant que caps lock est tenu enfoncé, applique le modificateur ctrl aux +# autres touches +setxkbmap -option caps:ctrl_modifier + +# quand caps lock est relâché il agit comme esc +xcape -e 'Caps_Lock=Escape' + +# finelement, active le layout QWERTY-fr +setxkbmap -v -layout us_qwerty-fr +``` + +J'ai aussi activé le module `xkeyboard` pour [polybar](https://github.com/polybar/polybar), pour que je puisse voir facilement quel layout est activé. + +## Un dictionnaire + +Finalement, je voulais un dictionnaire plus complet que mes simples scripts de traduction. + +C'est surtout agin de m'aider à apprendre à grammaticalement genrer les mots, ce que mes scripts ne réussissent que partiellement. + +C'est également une bonne pratique d'apprendre la définition des mots en ne ce servant de cette langue! + +Je trouvé le dictionnaire ouvert StarDict, pour lequel existe le dictionnaire de terminal `sdvc`, et j'ai installé un dictionnaire français (Dictionnaire de l'Académie Française, 8ème edition (1935)) avec le paquet d'AUR `stardict-acadfr1935`. +Depuis que c'est le seulement dictionairre j'ai installé, l'utilisement a y c'est simple - je l'ai enveloppé dans un `mot` scripte: +Comme c'est le seul dictionnaire d'installé, l'utilisation est assez simple - je l'ai enveloppé dans un script `mot`: + +``` +#!/usr/bin/env bash + +# trouve le signification d'un mot français +sdcv -c -n $1 +``` + +Pour conclure, je ne suis pas encore satisfait avec ça, mais pour l'instant ça va faire l'affaire. +Le dictionnaire devrait inclure des définitions plus récentes et à jour, et l'ouput est souvent assez verbose. +La page d'ArchWiki décrit des usages possibles, je vais peut-êtres explorer ça dans le futur. + +Voilà, merci pour supporter ma français terrible, je suis finit! + +--- + +Également, merci à mon ami Québécois Vorty, qui a m'aidé avec mes terribles abilités des langues, en deux anglais et français. diff --git a/blogs/2022/3/21/todo-lists.md b/blogs/unfinished/todo-lists.md similarity index 100% rename from blogs/2022/3/21/todo-lists.md rename to blogs/unfinished/todo-lists.md