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
2 changes: 1 addition & 1 deletion assets/js/localization.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ function setLocale(newLocale /*: string */) {
return newLocale;
}

/*:: export {getLangByCode, getDynamicLocalization, iso639Codes, iso639CodesInverse, locale, localizeInterface, setLocale} */
/*:: export {getLangByCode, getDynamicLocalization, iso639Codes, iso639CodesInverse, locale, localizeInterface, setLocale, langDirection} */

/*:: import {curDstLang, curSrcLang, dstLangs, getPairs, populateTranslationList, refreshLangList, srcLangs} from "./translator.js" */
/*:: import {ajaxSend, ajaxComplete, getURLParam, modeEnabled, onlyUnique, sendEvent} from "./util.js" */
Expand Down
18 changes: 14 additions & 4 deletions assets/js/translator.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var PUNCTUATION_KEY_CODES = [46, 33, 58, 63, 47, 45, 190, 171, 49]; // eslint-di

/* global config, modeEnabled, synchronizeTextareaHeights, persistChoices, getLangByCode, sendEvent, onlyUnique, restoreChoices
getDynamicLocalization, locale, ajaxSend, ajaxComplete, localizeInterface, filterLangList, cache, readCache, iso639Codes,
callApy, apyRequestTimeout, isURL, removeSoftHyphens, parentLang, isVariant */
callApy, apyRequestTimeout, isURL, removeSoftHyphens, parentLang, isVariant, langDirection */
/* global ENTER_KEY_CODE, HTTP_BAD_REQUEST_CODE, HTTP_OK_CODE, SPACE_KEY_CODE, XHR_DONE, XHR_LOADING */

if(modeEnabled('translation')) {
Expand Down Expand Up @@ -554,10 +554,20 @@ function populateTranslationList() {

var minColumnWidth = TRANSLATION_LIST_MAX_WIDTH / TRANSLATION_LIST_MAX_COLUMNS;

// figure out how much space is actually available for the columns
var maxSrcLangsWidth = $(window).width() - $('#srcLanguagesDropdownTrigger').offset().left - TRANSLATION_LISTS_BUFFER,
var maxSrcLangsWidth, maxDstLangsWidth;

// figure out how much space is actually available for the columns, defaulting to ltr
var direction = locale ? langDirection(locale) : 'ltr';
if(direction === 'ltr') {
maxSrcLangsWidth = $(window).width() - $('#srcLanguagesDropdownTrigger').offset().left - TRANSLATION_LISTS_BUFFER;
maxDstLangsWidth = $('#dstLanguagesDropdownTrigger').offset().left + $('#dstLanguagesDropdownTrigger').outerWidth() -
TRANSLATION_LISTS_BUFFER;
}
else {
maxSrcLangsWidth = $('#srcLanguagesDropdownTrigger').offset().left + $('#srcLanguagesDropdownTrigger').outerWidth() -
TRANSLATION_LISTS_BUFFER;
maxDstLangsWidth = $(window).width() - $('#dstLanguagesDropdownTrigger').offset().left - TRANSLATION_LISTS_BUFFER;
}

// then, prevent all the columns from getting too wide
maxSrcLangsWidth = Math.min(TRANSLATION_LIST_MAX_WIDTH, maxSrcLangsWidth);
Expand Down Expand Up @@ -1270,6 +1280,6 @@ function setRecentDstLangs(langs /*: string[] */) {
apyRequestTimeout, removeSoftHyphens, parentLang, isVariant} from "./util.js" */
/*:: import {ENTER_KEY_CODE, HTTP_BAD_REQUEST_CODE, HTTP_OK_CODE, SPACE_KEY_CODE, XHR_DONE, XHR_LOADING} from "./util.js" */
/*:: import {persistChoices, restoreChoices} from "./persistence.js" */
/*:: import {localizeInterface, getLangByCode, getDynamicLocalization, locale, iso639Codes} from "./localization.js" */
/*:: import {localizeInterface, getLangByCode, getDynamicLocalization, locale, iso639Codes, langDirection} from "./localization.js" */
/*:: import {readCache, cache} from "./persistence.js" */
/*:: import {isURL} from "./util.js" */