-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
i18n rtl css support #900
i18n rtl css support #900
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const checkRTL = require('../static/js/rtl'); | ||
|
||
/** | ||
* Returns true if the given language is written from right to left (requires rtl css) | ||
* | ||
* @param {string} locale | ||
* @returns {boolean} | ||
*/ | ||
module.exports = function isRTL(locale) { | ||
return checkRTL(locale); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* Returns true if the given language is written from right to left (requires rtl css) | ||
* | ||
* @param {string} locale | ||
* @returns {boolean} | ||
*/ | ||
module.exports = function isRTL (locale) { | ||
if(locale === 'ar') { | ||
yen-tt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return true; | ||
} | ||
return false; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,8 @@ const HtmlPlugin = require('html-webpack-plugin'); | |
const RemovePlugin = require('remove-files-webpack-plugin'); | ||
const { merge } = require('webpack-merge'); | ||
const { parse } = require('comment-json'); | ||
const RtlCssPlugin = require('rtlcss-webpack-plugin'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just for my edification what kinds of transformations does this do? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's use, in addition to mini-css-extract-plugin we already have, to create a second rtl css bundle. It uses the rtlcss library under the hood that tom suggested on slack. I'm not sure if it fix most of the sprint items, this might have to apply to SDK css as well. The map error and the chevron change still needs to be fix. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From what I understand, dir="rtl" affects the direction property in CSS for text content flow within a block-level element. But it doesn't change the other styling like margin left/right and whatnots, which is what this plugin would take care of. so I don't think we will double flip things There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. awesome! |
||
const isRTL = require('./js/rtl'); | ||
|
||
module.exports = function () { | ||
const jamboConfig = require('./jambo.json'); | ||
|
@@ -33,6 +35,19 @@ module.exports = function () { | |
globalConfig = parse(globalConfigRaw); | ||
} | ||
|
||
const cssRtlPlugin = []; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with Connor using a list for a single item is strange, can't we just have it be let cssRtlPlugin;
//...
[
cssRtlPlugin,
...htmlPlugins
] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in the case that we don't need a cssRtlPlugin, it would have an undefined element in there and would throw an error when running webpack. I could move this chunk of code after There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. okay that's fair! |
||
const localeConfigPath = `./${jamboConfig.dirs.config}/locale_config.json`; | ||
if (fs.existsSync(localeConfigPath)) { | ||
localeConfigRaw = fs.readFileSync(localeConfigPath, 'utf-8'); | ||
localeConfig = parse(localeConfigRaw); | ||
const hasRtlLocale = Object.keys(localeConfig.localeConfig).some((locale) => isRTL(locale)); | ||
if(hasRtlLocale) { | ||
cssRtlPlugin.push(new RtlCssPlugin({ | ||
filename: '[name].rtl.css' | ||
})); | ||
} | ||
} | ||
|
||
const { useJWT } = globalConfig; | ||
|
||
let jamboInjectedData = process.env.JAMBO_INJECTED_DATA || null; | ||
|
@@ -53,6 +68,7 @@ module.exports = function () { | |
}[chunkName] || '[name].css' | ||
} | ||
}), | ||
...cssRtlPlugin, | ||
...htmlPlugins, | ||
new webpack.DefinePlugin({ | ||
'process.env.JAMBO_INJECTED_DATA': JSON.stringify(jamboInjectedData) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe this can go into static/webpack since it's only used as part of the build? right now static/js is for stuff that goes on the browser