-
Beim Denken zuhören - wie viel Spielraum hat ein Kanzler? -
Redirect
One way to redirect inside the rails router based on the client’s Accept-Language header.
Previously i thought i had to do this inside the proxy webserver nginx, only really possible with the lua-enhanced fork of openresty, or the selfcompiled nginx version.
Or to go into the rack middleware world and figure out how to do it there - it’s probably still the fastest, cleanest to do it there.
There are more ways above that: routes file, and of course application controller.
I went for the routes file and added this directive:
root to: redirect { |params, request| "/#{best_locale_from_request!(request)}" }, status: 302, as: :redirected_root
The curly braces syntax is obligatory, do/end block does not work.
The actual work is being done with the help of teh
accept_language
gem and these two methods, split up for easier reading i presume:def best_locale_from_request(request) return I18n.default_locale unless request.headers.key?("HTTP_ACCEPT_LANGUAGE") string = request.headers.fetch("HTTP_ACCEPT_LANGUAGE") locale = AcceptLanguage.parse(string).match(*I18n.available_locales) # If the server cannot serve any matching language, # it can theoretically send back a 406 (Not Acceptable) error code. # But, for a better user experience, this is rarely done and more # common way is to ignore the Accept-Language header in this case. return I18n.default_locale if locale.nil? locale end
I’ve put them both into the routes file, but there might be a better place for that.
The available locales array grew a bit, in order to prevent edge cases:
# config/application.rb config.i18n.available_locales = [:en, :"en-150", :"en-001", :"en-DE", :de, :"de-AT", :"de-CH", :"de-DE", :"de-BE", :"de-IT", :"de-LI", :"de-LU", :et, :"et-EE"]
turns out the gem always forwards the geography part as well, so in order to make sure nobody is left out, i’ve added this for now. this might become tricky later on as paths are created based on that, and the language switcher might be a bit more tricky. maybe it makes sense to cut the second part off somehow.
Resources:
Accept-Language gem: https://github.com/cyril/accept_language.rb
A rack app i did not get to work, but apparently does the i18n settings as well: https://github.com/blindsidenetworks/i18n-language-mapping
This was very helpful for the redirect syntax: https://www.paweldabrowski.com/articles/rails-routes-less-known-features
-
I shared a link
PERMALINK
Just how complicated could it be to register a German company?
Have you heard that it is complicated to start a business in Germany?gold! https://major-grooves.medium.com/just-how-complicated-could-it-be-to-register-a-german-company-e5eb6e50db79
-
I shared a link
PERMALINK
Home invasion - Mastodon's Eternal September begins
The fediverse is dealing with a huge wave of Twitter people bringing toxic ideas with them.https://www.hughrundle.net/home-invasion/
-
I shared a link
PERMALINK
Isabel Jezierska: 'Maybe it's time to speak out?'
Demonstrations by students and university staff in Estonia have, until now, been slow and infrequent. However, demonstrations are a natural part of a democratic society and a legitimate way to influence leaders to change their policies, writes Isabel Jezierska, MA student at the University of Tartu.https://news.err.ee/1608698500/isabel-jezierska-maybe-it-s-time-to-speak-out
-
I shared a link
PERMALINK
Gastbeitrag: Was der Westen über Putin (immer noch) nicht versteht
Die Frage, ob man Putin einen Ausweg aus dem Krieg eröffnen muss, ist nebensächlich: Er glaubt, dass er gewinnt. Der Westen muss die Situation anders betrachten, wenn er effektiver vorgehen will. -
I shared a link
PERMALINK
https://www.jetzt.de/ukraine/du-kannst-nur-pazifistin-sein-wenn-du-nicht-bedroht-wirst
-
I shared a link
PERMALINK
‘We Can Only Be Enemies’
One family’s experience of Russia’s invasion offers a path to the end of the war. -
I shared a link
PERMALINK
Liberal entrepreneurs ditching 'no-state-help' dogma, lawmakers are not
Every economic downturn brings changes to the market and Estonia is no different. The 2008 loan market collapse made Estonian companies think about financial reserves. The pandemic has changed e-Estonia's often individualistic business approach, as business leaders are calling for more state help. But the government doesn't seem to listen.and as always: privatise profits, socialise risks
-
I shared a link
PERMALINK
Ukraine-Krieg: Was eine Mutter auf den Rücken ihres Kindes schrieb
Aleksandra Makoviy schreibt kurz vor ihrer Flucht aus der Ukraine die wichtigsten Daten auf den Rücken ihrer Tochter. Was hat sie dazu... -
I shared a link
PERMALINK
Augenzeugen berichten von Exekutionen und Vergewaltigungen
Nach Aussagen von ukrainischen Geflüchteten haben russische Soldaten in Vororten von Kiew wehrlose Zivilisten getötet und Frauen vergewaltigt. RBB24 Recherche liegen entsprechende Augenzeugenberichte vor.“Der angeschossene Juri S. bricht zusammen. Er blutet stark. Die Soldaten schieben einen Deckel auf den Schacht und gehen ins Haus. Tatjana S. erinnert sich, wie sie hrten, dass sie das Haus durchsuchten. Mehrere Stunden sitzen Mutter und Tochter eingesperrt in dem Pumpenschacht. Der Atem von Juri S. wird von Stunde zu Stunde schwcher. Gegen 02.30 Uhr in der Nacht stirbt er.”
“Sie berichtet, dass Soldaten ihren Mann ermordet haben, nachdem sie eine Camouflage-Jacke in seinem Auto gefunden hatten. Der Mrder soll gesagt haben: “Ich habe ihn erschossen, weil er ein Nazi war.” Natalya* selbst sei von den Ttern mehrfach vergewaltigt worden, whrend ihr vierjhriger Sohn nebenan im Heizungsraum weinte.”
- Alle Sanktionen jetzt.
- Alle Waffenlieferungen jetzt.
- Ukraine in die EU jetzt.
- Russland raus aus allen internationalen Vertrgen und Organisation jetzt.
-
I shared a link
PERMALINK
'Why? Why? Why?' Ukraine's Mariupol descends into despair
In the more than two weeks since Russia’s war began, two AP journalists have been the only international media present in Mariupol, chronicling its fall into chaos and despair. -
I shared a link
PERMALINK
Attention Required! | Cloudflare
This website is using a security service to protect itself from online attacks. The action you just performed triggered the security solution. There are several actions that could trigger this block including submitting a certain word or phrase, a SQL command or malformed data. -
I shared a link
PERMALINK
Ukraine events strike too familiar of a chord among older Estonians
Horrific events in Ukraine spark a frightful sense of deja vu for many older Estonians, as does the West's repeated failure to see, in time, Russia as the serial predator suffering from a phantom limb sensation that it really is, Jüri Estam writes.https://news.err.ee/1608524786/ukraine-events-strike-too-familiar-of-a-chord-among-older-estonians
-
I shared a link
PERMALINK
The American Pundits Who Can’t Resist “Westsplaining” Ukraine
John Mearsheimer and other foreign policy figures are treating Russia’s invasion of Ukraine like a game of Risk.https://newrepublic.com/article/165603/carlson-russia-ukraine-imperialism-nato
-
I shared a link
PERMALINK
Wer ist Peter Thiel? | ZDF Magazin Royale
Bibelkenner, Visionär, Gründer, Investor, Manager, Republikaner, Politikberater, Multimilliardär und einer der besten Schachspieler der USA. Nein, das ist ni...ganz groes kino https://youtu.be/SKY5pOcEn4U?t=1222
-
Moving lvm-thin volumes on proxmox between vm-s or ct-s
Following this official howto
lvs
shows you all volumes in their volume group (in my case ‘ssd’)LV VG Attr LSize Pool Data% Meta% data pve twi-a-tz-- 32.12g 0.00 1.58 root pve -wi-ao---- 16.75g swap pve -wi-ao---- 8.00g guests ssd twi-aotz-- <2.33t 74.93 45.51 vm-100-disk-0 ssd Vwi-a-tz-- 12.00g guests 72.69 vm-101-disk-0 ssd Vwi-a-tz-- 12.00g guests 85.22 vm-101-disk-1 ssd Vwi-a-tz-- 50.00g guests 99.95 vm-102-disk-0 ssd Vwi-a-tz-- 12.00g guests 97.57 vm-102-disk-1 ssd Vwi-a-tz-- 50.00g guests 64.54 vm-103-disk-0 ssd Vwi-a-tz-- 12.00g guests 74.37 vm-103-disk-1 ssd Vwi-a-tz-- 150.00g guests 52.42 vm-104-disk-0 ssd Vwi-a-tz-- 12.00g guests 90.74 vm-104-disk-1 ssd Vwi-a-tz-- 10.00g guests 95.27 vm-105-disk-0 ssd Vwi-a-tz-- 12.00g guests 55.79 vm-105-disk-1 ssd Vwi-a-tz-- 10.00g guests 32.89 vm-106-disk-0 ssd Vwi-a-tz-- 12.00g guests 77.78 vm-106-disk-1 ssd Vwi-a-tz-- 10.00g guests 99.82 vm-107-disk-0 ssd Vwi-a-tz-- 32.00g guests 0.00 vm-107-disk-1 ssd Vwi-a-tz-- 500.00g guests 95.41 vm-108-disk-0 ssd Vwi-aotz-- 8.00g guests 43.73 vm-109-disk-0 ssd Vwi-a-tz-- 12.00g guests 52.41 vm-109-disk-1 ssd Vwi-a-tz-- 50.00g guests 2.22 vm-110-disk-0 ssd Vwi-a-tz-- 12.00g guests 51.14 vm-110-disk-1 ssd Vwi-a-tz-- 50.00g guests 2.22 vm-111-disk-0 ssd Vwi-a-tz-- 12.00g guests 84.85 vm-111-disk-1 ssd Vwi-a-tz-- 100.00g guests 16.97 vm-112-disk-0 ssd Vwi-a-tz-- 8.00g guests 13.53 vm-113-disk-0 ssd Vwi-a-tz-- 8.00g guests 11.55 vm-114-disk-0 ssd Vwi-a-tz-- 16.00g guests 84.31 vm-115-disk-0 ssd Vwi-a-tz-- 16.00g guests 97.12 vm-116-disk-0 ssd Vwi-a-tz-- 8.00g guests 31.49 vm-117-cloudinit ssd Vwi-aotz-- 4.00m guests 50.00 vm-117-disk-0 ssd Vwi-aotz-- 10.00g guests 39.71 vm-117-disk-1 ssd Vwi-aotz-- 1000.00g guests 97.47
If the id of the new ct or vm is not equal to the id of the volume’s previous attachment, rename them, i.e.
lvrename ssd/vm-101-disk-1 ssd/vm-117-disk-2
This will make vm-101-disk-1 available as vm-117-disk-2, you have to increase the count in the end of the name.
Then edit the config of the actual vm.
Take the line from
/etc/pve/qemu-server/<vm id>.conf
that describes the volume to the new<vm id>.conf
The tricky thing was to run
qm rescan
afterwards which fixed syntax and made the volume appear in the web gui where i could finally attache it to the new vm. -
I shared a link
PERMALINK
CCC | CCC veröffentlicht Formulierungshilfe für Digitales im neuen Regierungsprogramm
Endlich ein solides Regierungsprogramm für unsere digitalisierte Welt, wer wünscht sich das nicht? Wir machen hiermit einen Vorschlag. Kürzer konnten wir es leider nicht hinbekommen, denn es hat sich ja einiges aufgestaut. -
I shared a link
PERMALINK
Wahlchaos in Berlin: Nicht mehr lustig
Dit is Berlin? In Zeiten von Fake News ist das Chaos in den Berliner Wahllokalen leider nicht mehr lustig.https://www.sueddeutsche.de/meinung/berlin-bundestagswahl-wahllokale-demokratie-kommentar-1.5426410
-
I shared a link
PERMALINK
Erdrutschsieg der Kommunisten in Graz: Woher rührt der Erfolg, und wo will die KPÖ hin?
Die zweitgrößte Stadt Österreichs könnte mit Elke Kahr erstmals eine kommunistische Bürgermeisterin bekommen. Eine Analyse des Sensationswahlsiegs der KPÖ in Grazhier, Linke, guckt ma:
https://www.derstandard.at/story/2000129973927/erdrutschsieg-der-kommunisten-in-grazwoher-ruehrt-der-erfolg-und-wo
-
I shared a link
PERMALINK
AfD auf dem Weg zur "Lega Ost"?
Fünf Prozent in Hamburg, knapp 25 Prozent in Sachsen: Bei der AfD zeigt sich die Republik geteilt. Insgesamt ging es bei der Bundestagswahl abwärts für die...hach ja, was soll mer da noch sagen,,,
-
I shared a link
PERMALINK
Kõlvart koondas linna transpordijuhi Rüütelmaa: tema töö ei olnud kiita
Tallinna linnapea Mihhail Kõlvart (KE) kinnitas Postimehele, et Tallinna Transpordiameti asejuhataja Talvo Rüütelmaaga lõpetati koostöö.wow, is that some sort of early election gift?
-
I shared a link
PERMALINK
Angst vor der Rache der Taliban: Der digitale Notausgang fehlt
Smartphones, soziale Netzwerke und Biometrie-Datenbanken: Digitale Spuren können Frauen und Männer in Afghanistan an die Taliban verraten. Aus diesem Albtraumszenario sollte der Westen etwas lernen.Moneyquote: “Digitale Spuren knnen Frauen und Mnner in Afghanistan an die Taliban verraten. Aus diesem Albtraumszenario sollte der Westen etwas lernen.”
-
I shared a link
PERMALINK
Kaks meest kahest ehk Nädalalõpu poliitikasaadete välimääraja | Müürileht
Nädalat kokku võttev arutelusaade on iga raadiojaama au ja uhkus. Mida info ülekülluse keskel võtta, mida jätta ja millest puudu on? -
I shared a link
PERMALINK
UK councils to display EU flags after UK dips into Covid recovery cash
"This shows the absurd hypocrisy of this Conservative government," Liberal Democrat Christine Jardine said.textbook example of the power of symbols
- ← Newer Posts Page: 2 of 38
- Older Posts →