Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

bug 1379288: Include optional locale-specific CSS #4303

Merged
merged 2 commits into from
Jul 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@ const watch = require('gulp-watch');

// compiles top-level .scss files
gulp.task('styles', () => {
// only process files in /styles root
// all other .scss files are components/includes/libs
// Process files in /styles root
gulp.src('./kuma/static/styles/*.scss')
.pipe(sass().on('error', sass.logError))
// send compiled files to where expected by Django Pipeline
.pipe(gulp.dest('./static/styles'));
// Process files in /styles/locales
gulp.src('./kuma/static/styles/locales/*.scss')
.pipe(sass().on('error', sass.logError))
// send compiled files to where expected by Django Pipeline
.pipe(gulp.dest('./static/styles/locales'));
});

// lints .scss files with stylelint
Expand Down
3 changes: 3 additions & 0 deletions jinja2/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
{% stylesheet 'maintenance-mode-global' %}
{%- endif %}

{#- If the stylesheet exists, include it. Otherwise, does nothing. #}
{% stylesheet 'locale-%s' % LANG %}

{%- if not is_sphinx %}
<!-- common social tags -->
{% set social_logo = request.build_absolute_uri(static('img/opengraph-logo.png')) %}
Expand Down
16 changes: 16 additions & 0 deletions kuma/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,21 @@ def enable_candidate_languages():
# Cache non-versioned static files for one week
WHITENOISE_MAX_AGE = 60 * 60 * 24 * 7


def pipeline_scss(output, sources):
"""Define a CSS file generated from multiple SCSS files."""
definition = {
'source_filenames': tuple('styles/%s.scss' % src for src in sources),
'output_filename': 'build/styles/%s.css' % output
}
return definition


def pipeline_one_scss(slug):
"""Define a CSS file that shares the name with the one input SCSS."""
return pipeline_scss(slug, [slug])


PIPELINE_CSS = {
'mdn-blue': {
'source_filenames': (
Expand Down Expand Up @@ -885,6 +900,7 @@ def enable_candidate_languages():
),
'output_filename': 'build/styles/samples.css',
},
'locale-zh-CN': pipeline_one_scss('locales/zh-CN')
}

PIPELINE_JS = {
Expand Down
3 changes: 3 additions & 0 deletions kuma/static/styles/locales/zh-CN.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/*
Styles for Chinese (Simplified)
********************************************************************** */