Hacker News new | ask | show | jobs
by Theodores 5 days ago
Very interesting, but also quite sad that today's renderers ignore the finer points of the specification.

On a related note, I like the ability of good old HTML to be able to change text for different human readers, based on their chosen locale. With this I can change units such as litres to 'fluid flagon ounces' or whatever it is they use in the USA, or I can drop in a friendly greeting in a foreign language. I have not seen this done in the wild, usually it is a trip back to the server for a different locale, or the server does the locale reading before sending the page.

As for our AI overlords, HTML5 content sectioning markup done to HTML5 specifications should be helpful, yet I have yet to see this done in the wild.

PDF has its uses but CSS for print interests me far more. I am not in a hurry to learn the PDF spec, but HTML/CSS/SVG specifications do interest me. I doubt I am alone in this, so I would prefer to get my HTML fully accessible to all, to make PDF a 'nice to have', just churned out with some type of headless webkit renderer, server side.

1 comments

What part of HTML is letting you adapt e.g. units of measurement by locale? Presumably there's also CSD and JS involved?
Imagine an article about sidewalks, there could be an explainer for Brits that explains that 'they mean the pavement' and another about 'customary units'. Americans would not need the explainers, so they could be made visible only to international readers with:

   [lang=en-us] aside { display:none; }
But lang in this case would be a property of the document itself, not the user agent, right?

I can't see a way in CSS to detect the user agent preferred language, but you could do this in JS and add another attribute to the document or whatever.

Correct!

It has been a year since I last checked, and I did use JS and 'navigator'.

However, importantly for me, I was able to avoid a trip back to the server for the few bits I wanted - introduction - in different locales.

Actually, I looked into it some more, and SVG Switch, which should do stuff based on browser locale.

However, it was showing me 'en-US' not 'en-GB'. There is a bug in SVG switch that means it can do languages automagically but not variants. This I can work with, but it is still something unexpected and unlikely to be fixed because nobody cares about SVG.

Not sure about HTML, but you can use `<switch>` [1] in SVG and it will display localized text based on the `system’anguage` property.

[1]: https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/E...

Switch has some gnarly options with it, and I do want to find an excuse to use it in my 'SVG embroidery sampler'.

Flags are a possibility, although I only have the UK flag in my SVG sprite sheet thus far.

I will have to see if I can build a usefully stylish locale switcher that gets it right the first time due to browser locale, yet is changeable, with option stored in local storage, all inside the SVG Shadow DOM...