Ruby language access in CSS files

Therefore, I use CSS, JS and Ruby for the project. Now I have my location, etc., in ruby, but I want to access them in my css files. This is necessary to customize the views for a specific locale. In my controller, I did the following.

before_filter :set_locale private def set_locale @locale ||= params[:locale] || session[:locale] || I18n.default_locale I18n.locale = session[:locale] = @locale end 

How do I access this installation location in my CSS files? for example, to say that if the location is Russia, then do a height of 200 px or something like that.

+3
source share
1 answer

You can add the current language to the html tag as lang. for instance

 %html{lang: I18n.locale} <html lang="en"> or <html lang="ru"> 

and add a specific language style with a language prefix

 html[lang="en"] { # for english part } html[lang="ru"] { # for russian part } 

also you can change the behavior of an existing class

 .test-title { html[lang="en"] & { // specific english style } } 
+8
source

Source: https://habr.com/ru/post/908607/


All Articles