4 ms·
https://github.com/alexpovel/srgn https://github.com/alexpovel/srgn It grew out of a niche, almost historical need: using a QWERTY keyboard, but needing access
by alexpovel 3y ago
https://github.com/alexpovel/srgn https://github.com/alexpovel/srgn
It grew out of a niche, almost historical need: using a QWERTY keyboard, but needing access to German Umlauts (ä, ö, ü, as well as ß). Switching keyboard layouts is possible but exhausting (it's much more pleasant sticking to one); using modifier keys is similarly tedious, and custom setups break and aren't portable.
So this tool can do:
$ echo 'Gruess Gott, Poeten und Abenteuergruetze!' | srgn --german
Grüß Gott, Poeten und Abenteuergrütze!
meaning it not only replaces Umlauts and Eszett, it also knows when not to (Poeten), and handles arbitrary compound words. Write your text, slap it all into the tool, it spits out results instantly. The original text can use alternative spellings (ou, ae, ue, ss), which is ergonomic. Combined with tools like AutohotKey, GUI integration through a single keyboard shortcut is possible. See [0] for a similar example.
A niche need I haven't yet come across someone else having as well! (just the amount of text explaining what it's all about is saying a lot in terms of specificity...)
The tool now grew into a tree-sitter based (== language grammar-aware) text manipulation thing, mostly for fun. The bizarre German core is still there however.
[0]: https://github.com/alexpovel/betterletter/blob/c19245bf90589aff7fad744981202ae370d66a51/betterletter.ahk https://github.com/alexpovel/betterletter/blob/c19245bf90589...
- akoboldfrying 3y agoI had this need! Did you opt to blacklist words with vowel combinations that should not be transformed, or whitelist those that should? Or something else entirely?
- alexpovel 3y agoIt's currently whitelist-based [0]. The downside is larger (code) size. The upside is simplicity. I imagine a blacklist could also work well, at smaller size but with more preprocessing needed. [0]: https://github.com/alexpovel/srgn/blob/0008cce1c71f0d83f6a3186837fb6d1074236424/data/word-lists/de.txt https://github.com/alexpovel/srgn/blob/0008cce1c71f0d83f6a31...
- akirk 3y agoI also use a QWERTY keyboard and I use a custom keyboard layout that maps alt-a to ä, alt-u to ü, alt-o to ö, alt-s to ß (plus the same for uppercase for the first 3). That works well for me without the need to post-process. On macOS it's relatively easy to create using a tool called Ukulele (https://software.sil.org/ukelele/ https://software.sil.org/ukelele/). You can also download my layout here: https://alex.kirk.at/USUmlaut.keylayout https://alex.kirk.at/USUmlaut.keylayout
- xmodem 3y agoOn macOS you can also access related symbols by long-pressing keys. Obviously for large blocks of text you're still going to want to switch layouts but for a quick IM reply or typing a couple of characters I think it's faster.
- dewey 3y agoThe faster way is to press Option + U and then the letter u for ü or a for ä. Have been using a US keyboard since before this long press feature came over from iOS and it’s way faster that way.
- RamblingCTO 3y agoI just use "US international PC" which allows using ä etc. by typing " and then combining it with a, u etc.
- eviks 3y agoYou can do the same on Windows with an AutoHotkey solution
- sgjohnson 3y agoI’ve done the same exact thing but for Latvian diacriticals (āčēģīķļņšūž). The default behaviour of the Latvian layout in macOS is to make apostrophe a dead key, which really grinds my gears. So I made it alt+whatever letter instead. As a dev I use apostrophe way too much to be okay with typing '+space for it.
- mid-kid 3y agoThis is why I stick to layouts with separate keys for " and the dead-key ¨ Plenty of european layouts with qwerty and the necessary dead keys, that work on every OS.
- deleted 3y ago[deleted]
- tunnuz 3y agoThe greeting seems Austrian?
- mzi 3y agoOn different flavors of *nix you have "compose character" that helps you with that. In my sway config I have xkb_options grp:win_space_toggle,compose:caps and then I can do compose ss for ß or compose SS for ẞ. https://en.wikipedia.org/wiki/Compose_key https://en.wikipedia.org/wiki/Compose_key
- andrybak 3y agoWinCompose covers nicely the lack of *nix compose key in Windows. https://github.com/samhocevar/wincompose https://github.com/samhocevar/wincompose
- netsharc 3y agoI've been thinking about a tool to format a number where the common display format is abc.defg.hijk.lmn (but I'd be retrieving it from an e.g. database without the periods), the sample AutoHotkey script is a great starting point!
- eviks 3y ago> custom setups break and aren't portable But this is a custom setup that's not portable? And how is it less tedious to have to select previously typed text all the time? Is it mainly better because then you don't need to do anything on individual chars, but do it in a batch?
- alexpovel 3y ago> But this is a custom setup that's not portable? Caught me. > And how is it less tedious to have to select previously typed text all the time? This is tedious, but I have that automated (AutoHotKey). So a single, AHK-managed hotkey does the equivalent of: CTRL + SHIFT + HOME CTRL + C feed into tool, paste back CTRL + V So once done writing, I press that single button and it's done (CTRL+SHIFT+HOME select all text from cursor to beginning). To me, that's a better tradeoff than fiddling with compose keys, which I find to break flow. For very short text, compose key is possibly better; but again, once in AHK, it's a single shortcut. So once more than 1 compose key combination is needed, it's "worth it". But you're right: this is a custom setup and might not work for everyone.
- eviks 3y agoOh, I didn't see the "CTRL + SHIFT + HOME" part in the linked AHK script, only the later steps, that's definitely less tedious, though also more dangerous (wouldn't work in rich text apps with tables and pictures etc.? though maybe your tool is smart enough to deal with rich text in the clipboard) and also pollutes the undo buffer. Agree re. the potential to break flow part of the compose keys in general (all these grammar things should be automated away), though maybe in case of needing just a single diacritic the least fiddly alternative could be something like a hotstring in AHK ",u" to "ü" (comma + a letter without spaces, which doesn't happen in regular typing or a deadkey in keyboard layout with a similar effect)
- rft 3y agoNow that is a tool I never knew I needed, great idea! I get by with the compose key or just googling the Umlaut if I have not set it up. I guess I have just nerdsniped myself into building a script/hack that can automatically edit the clipboard and/or selected text on button press. There goes my weekend, but thank you for building this part!