0
Welcome Guest! Login
0 items Join Now

language-specific CSS rules & compiled CSS files

    • Randy Carey's Avatar
    • Randy Carey
    • Rocketeer
    • Posts: 77
    • Thanks: 0
    • web architect, book/magazine author

    language-specific CSS rules & compiled CSS files

    Posted 12 years 6 months ago
    • I have been using a custom feature for adding CSS files to a project, and when I turn on CSS compression, Gantry includes the CSS code from my custom files into the compiled file.

      Now I'm working on a multi-lingual site and I have needs to add a set of CSS rules specifc to the language. I know how to test for the language and (through a custom Gantry feature) conditionally include these language-specific CSS files.

      My question -- Since a CSS file is conditionally added through a feature, is Gantry capable of handling this condition when CSS is compiled (so that the Deutsche CSS file is included only for German, and the English CSS is included only when the current language is English?

      ...and if needed, can you recommend a better way to conditionally include language-specific CSS files?
    • Henning's Avatar
    • Henning
    • Preeminent Rocketeer
    • Posts: 29362
    • Thanks: 954
    • Volunteer

    Re: language-specific CSS rules & compiled CSS files

    Posted 12 years 6 months ago
    • you can build language specific rules via css like ...

      html[lang="de-de"] a#rt-logo {background-image: url(../images/logo/preset2/logo-de.png)!important;}

      just to use an example.
    • Randy Carey's Avatar
    • Randy Carey
    • Rocketeer
    • Posts: 77
    • Thanks: 0
    • web architect, book/magazine author

    Re: language-specific CSS rules & compiled CSS files

    Posted 12 years 6 months ago
    • Wow, thanks for the insight on that CSS technique.

      I'm still wondering, though... The site I'm working on is large (20+ menu items, 130+ articles, 70 modules, and all replicated for 5 languages). Perhaps its not a problem to add a couple hundred more CSS rules, but I was thinking it would be nice to isolate and conditionally send language-specific CSS code (similar to browser specific CSS code). If there is reason for CSS compression, then there seems to be a reason for including only what CSS rules are needed for the given context (e.g., the current language). Is this a valid concern?
    • Henning's Avatar
    • Henning
    • Preeminent Rocketeer
    • Posts: 29362
    • Thanks: 954
    • Volunteer

    Re: language-specific CSS rules & compiled CSS files

    Posted 12 years 6 months ago
    • you could use css files like this ...

      templates/rt_metropolis/css/language-en-GB.css
      templates/rt_metropolis/css/language-de-DE.css
      etc.

      just drop the File I attached feature into the features folder of the template .
      replace rt_metropolis with the name of your template.

      [File and code changed .... see below]
    • Randy Carey's Avatar
    • Randy Carey
    • Rocketeer
    • Posts: 77
    • Thanks: 0
    • web architect, book/magazine author

    Re: language-specific CSS rules & compiled CSS files

    Posted 12 years 6 months ago
    • Thanks much! Gantry is truly a robust and flexible platform.
    • Henning's Avatar
    • Henning
    • Preeminent Rocketeer
    • Posts: 29362
    • Thanks: 954
    • Volunteer

    Re: language-specific CSS rules & compiled CSS files

    Posted 12 years 6 months ago
    • Do'h! Accidently I deleted a post by RCarey ...
      Here it is again


      Henning,

      I got the feature to pull in a language-specific file, but only after a
      change of the code. I could not get any text value from
      $this->language
      Instead, I used this code snippet:
      $userLanguage = JFactory::getLanguage();   
      $gantry->addStyle('language-'.$userLanguage->getTag().'.css');
      ...and the returned tag value has the country portion in uppercase:
      de-DE

      Thought I'd report this in case someone else later reads this thread and
      wants to try the solution.

Time to create page: 0.066 seconds