Skip to content
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
4 changes: 2 additions & 2 deletions src/components/sprite-selector/sprite-selector.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import SpriteInfo from '../../containers/sprite-info.jsx';
import SpriteList from './sprite-list.jsx';
import ActionMenu from '../action-menu/action-menu.jsx';
import {STAGE_DISPLAY_SIZES} from '../../lib/layout-constants';
import {rtlLocales} from '../../lib/locale-utils';
import {isRtl} from 'scratch-l10n';

import styles from './sprite-selector.css';

Expand Down Expand Up @@ -140,7 +140,7 @@ const SpriteSelectorComponent = function (props) {
}
]}
title={intl.formatMessage(messages.addSpriteFromLibrary)}
tooltipPlace={rtlLocales.indexOf(intl.locale) === -1 ? 'left' : 'right'}
tooltipPlace={isRtl(intl.locale) ? 'left' : 'right'}
onClick={onNewSpriteClick}
/>
</Box>
Expand Down
14 changes: 10 additions & 4 deletions src/lib/locale-utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// TODO: this probably should be coming from scratch-l10n
// Tracking in https://github.com/LLK/scratch-l10n/issues/32
const rtlLocales = ['he'];
/**
* @fileoverview
* Utility functions related to localization specific to the GUI
*/

const wideLocales = [
'ab',
Expand All @@ -16,12 +17,17 @@ const wideLocales = [
'vi'
];

/**
* Identify the languages where translations are too long to fit in fixed width parts of the gui.
* @param {string} locale The current locale.
* @return {bool} true if translations in this language are too long
*/

const isWideLocale = locale => (
wideLocales.indexOf(locale) !== -1
);

export {
rtlLocales,
wideLocales,
isWideLocale
};
6 changes: 3 additions & 3 deletions src/reducers/locales.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {addLocaleData} from 'react-intl';

import {localeData} from 'scratch-l10n';
import editorMessages from 'scratch-l10n/locales/editor-msgs';
import {rtlLocales} from '../lib/locale-utils';
import {isRtl} from 'scratch-l10n';

addLocaleData(localeData);

Expand All @@ -21,7 +21,7 @@ const reducer = function (state, action) {
switch (action.type) {
case SELECT_LOCALE:
return Object.assign({}, state, {
isRtl: rtlLocales.indexOf(action.locale) !== -1,
isRtl: isRtl(action.locale),
locale: action.locale,
messagesByLocale: state.messagesByLocale,
messages: state.messagesByLocale[action.locale]
Expand Down Expand Up @@ -57,7 +57,7 @@ const initLocale = function (currentState, locale) {
{},
currentState,
{
isRtl: rtlLocales.indexOf(locale) !== -1,
isRtl: isRtl(locale),
locale: locale,
messagesByLocale: currentState.messagesByLocale,
messages: currentState.messagesByLocale[locale]
Expand Down