1

I am use Offline.js. Offline.js is a library to automatically alert your users when they've lost internet connectivity.

The Offline.js provide the different language in the css file but each one language contains his css file.

In my website I detect user language and I show the words in his language for a good user experience.

Can you adapt this library for that?

Thanks

saeta
  • 4,048
  • 2
  • 31
  • 48

1 Answers1

0

If you use less, you can import contextualize the css like this:

@import (inline) '../../bower_components/offline/themes/offline-theme-default.css';

.language-de {
  @import (less) '../../bower_components/offline/themes/offline-language-german.css';
}

.language-en {
  @import (less) '../../bower_components/offline/themes/offline-language-english.css';
}

You can then switch the language by setting the language-... class on your <body> element for example.

UPDATE: If you use the cleancss tool, make sure that you add '@charset "UTF-8";' in your main LESS file... otherwise there will be an @charset inside a block and cleanncss will mess up your CSS.

UPDATE: SASS can import css as well. Like that:

@import '../../bower_components/offline/themes/offline-theme-default';

.language-de {
  @import '../../bower_components/offline/themes/offline-language-german';
}

.language-en {
  @import '../../bower_components/offline/themes/offline-language-english';
}
André B.
  • 669
  • 5
  • 8