Forem Creators and Builders 🌱

yheuhtozr
yheuhtozr

Posted on • Updated on

Support language property in articles

Currently we don't see much progress (at least from outside) in the i18n of Forem. As I now have a motivationβ€”or needs to implement things toward it, I would like to propose a few potentially useful features and hear from the community. I may create a PR with the described spec if people see fit. Any suggestions are welcome.


(Human) language property for articles

Overview

Attach a property that indicates what language a post is written in. It will be integrated as a part of model and reflected on the page as an HTML lang attribute. Thus, its value is required to be specified in the BCP 47 syntax, but the author can choose one from a list of available options in the editor UI.
Additionally, users can declare their own preference of language to draft a post in the user settings. If set, it is prefilled on the editor for them.

This property can serve as a basis of other i18n-related features; for example one can easily implement a writing direction control logic for an article with CSS depending on the language value.

IIUC It can be independently added to the current build of Forem (as of Aug 16, 2021), without interacting with any other functions.

Related

Optional language field for articles #4168

Is your feature request related to a problem? Please describe. Nope, no problem!

Describe the solution you'd like An optional language field for an article so one can search or filter articles by their language.

Describe alternatives you've considered One could use the normal existing tags for that, but I think an actual designated tag on the article might be better.

Additional context None that I can think of right now!

Spec

Model

  • add text_lang string attribute/column to Article
  • add writing_lang string attribute/column to User
  • validate those fields with e.g. /[-a-zA-Z0-9]+/ or /[a-ZA-Z]{1,3}(-[a-zA-Z0-9]{1,8})*/ etc. (it depends to what degree you seriously do)

View

  • add a text field-cum-select (same one in Series selector) to set/show text_lang in the post option pop-up of editor UI (v2)
    • the field should be pre-populated by text_lang (if already set) β†’ writing_lang β†’ default (nothing, or en?)
  • apply the text_lang value to the lang attribute of the <article> element in the editor preview UI (v2)
  • apply the text_lang value to the lang attribute of the <article> element in the post view
  • add a text field-cum-select to set/show writing_lang in the user settings view under [Customization] β†’ [Writing]

other

  • get a list of known locales here

Top comments (3)

Collapse
 
ben profile image
Ben Halpern

We had this in place a little while ago and removed it because our first iteration wasn't well thought out enough.

Currently re-organizing our internal process and will hopefully be able to better account for this type of work in the near future.

Collapse
 
yheuhtozr profile image
yheuhtozr • Edited

Hi, thank you for the information. Can you perhaps share the details (and what was wrong) in the previous attempt? What I have only found is github.com/forem/forem/issues/4168, but no sign that it's actualized.

Edit: I'd also like to know if my suggested design suffers from the same pitfall.

Collapse
 
9comindia profile image
9comindia • Edited

This would be a great leap ahead, if implemented.
Multi-language users can co-exist on the same FOREM instance like unity in diversity.