php - Is there a way to append a CSS file with additional styles when needed? -
I work on the site that pulls into many CSS files, some of them are language-specific overrides for international users (We change some styles, so the long string of translated text can not break the layout) So we have something like French CSS, Spanish quas etc. When a user clicks on our language switcher, the page tag reloads with a particular class on the page tag. This way the page raises other styles.
One of our goals in the near future is that only serve our international users, a language-specific file is suitable for them. Well, despite all the styles they are not necessary. At the same time, one of the managers wants to integrate our style into a file so that http requests can be reduced. How can we have a CSS file without overwriting our language for each user? Is there a way to add styles to a main CSS file when necessary? We use Compass SASS; Is there a way to compile different versions of our main file, which includes a Spanish style, contains French styles, etc.? Ideally, we do not want to do different versions of our main CSS file in our working directory, because we support 25 total languages. In addition, our developers use PHP and Javascript, if someone has solutions that use these programming languages.
Edit - I should clarify whether there is a script or function that will block the style blocks from a CSS file and add them directly to another, which will be a main CSS file on a user CD ? It will only be executed if a user changes the choice of our language on our site. Or, since we are using SASS, there is no way in the framework that the compiler prepares 25 CSS versions of our main SQSS, each contains specific language overrides (25 .scss in the root of our SAS directory Without versions)?
You can do that by using php. You need to create a php file that can include all your CSS and include it in your index file:
& lt; Link rel = "stylesheet" type = "text / css" href = "css_file.php" & gt;
Then you will have to create css_file.php and use the following code:
Edit:
If the language variable is not present in your code, you can get a language from the session:
Edit: If you want to load different CSS files then you need to add the following php code to your index file:
& Lt ;? Php session_start (); // Receive language variables from active session $ language = $ _SESSION ['langar']; If ($ language == "en") {// English CSS file load echo "
If the name of the language session is the same as the CSS file, then you can use it:
Comments
Post a Comment