Skip to content
Open
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
30 changes: 30 additions & 0 deletions app/back-end/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,12 +366,36 @@ class App {
if (languageConfig) {
this.currentLanguageMomentLocale = languageConfig.momentLocale;
this.currentWysiwygTranslation = languagesLoader.loadWysiwygTranslation(this.appConfig.language, this.appConfig.languageType);
this.currentLanguageDirection = this.resolveLanguageDirection(this.appConfig.language, languageConfig.direction);
} else {
this.currentLanguageDirection = this.resolveLanguageDirection(this.appConfig.language);
}
} else {
this.currentLanguageDirection = 'ltr';
}

this.loadDefaultLanguage(languagesLoader, false);
}

/**
* Resolve UI text direction for a language pack.
* config.direction ("rtl"|"ltr") wins; otherwise known RTL roots (fa, ar, he, …).
*/
resolveLanguageDirection (languageCode, explicitDirection) {
if (explicitDirection === 'rtl' || explicitDirection === 'ltr') {
return explicitDirection;
}

if (!languageCode || typeof languageCode !== 'string') {
return 'ltr';
}

let root = languageCode.toLowerCase().replace(/_/g, '-').split('-')[0];
let rtlRoots = ['ar', 'fa', 'he', 'iw', 'ur', 'yi', 'ps', 'sd', 'ckb', 'ku', 'dv', 'ug', 'syr', 'arc'];

return rtlRoots.indexOf(root) > -1 ? 'rtl' : 'ltr';
}

// Load plugins
loadPlugins() {
let pluginsLoader = new Plugins(this.appDir, this.sitesDir);
Expand Down Expand Up @@ -410,6 +434,9 @@ class App {
if (languageConfig) {
this.currentLanguageMomentLocale = languageConfig.momentLocale;
this.currentWysiwygTranslation = languagesLoader.loadWysiwygTranslation(lang, type);
this.currentLanguageDirection = this.resolveLanguageDirection(lang, languageConfig.direction);
} else {
this.currentLanguageDirection = this.resolveLanguageDirection(lang);
}

if (
Expand All @@ -430,6 +457,7 @@ class App {

this.appConfig.language = lang.replace(/[^a-z\-\_\.]/gmi, '');
this.appConfig.languageType = type;
this.appConfig.languageDirection = this.currentLanguageDirection || this.resolveLanguageDirection(lang);

try {
fs.writeFileSync(this.appConfigPath, JSON.stringify(this.appConfig, null, 4), {'flags': 'w'});
Expand Down Expand Up @@ -675,13 +703,15 @@ class App {
translations: self.currentLanguageTranslations,
wysiwygTranslation: self.currentWysiwygTranslation,
momentLocale: self.currentLanguageMomentLocale,
direction: self.currentLanguageDirection || 'ltr',
languageLoadingError: self.languageLoadingError
},
defaultLanguage: {
name: self.defaultLanguageName,
translations: self.defaultLanguageTranslations,
wysiwygTranslation: self.defaultWysiwygTranslation,
momentLocale: self.defaultLanguageMomentLocale,
direction: 'ltr',
languageLoadingError: self.languageLoadingError
},
languages: self.languages,
Expand Down
6 changes: 4 additions & 2 deletions app/back-end/languages.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ class Languages {
author: languageData.author,
publiiSupport: languageData.publiiSupport,
momentLocale: languageData.momentLocale,
wysiwygTranslation: languageData.wysiwygTranslation
wysiwygTranslation: languageData.wysiwygTranslation,
direction: languageData.direction || null
});
}

Expand Down Expand Up @@ -91,7 +92,8 @@ class Languages {
author: languageData.author,
publiiSupport: languageData.publiiSupport,
momentLocale: languageData.momentLocale,
wysiwygTranslation: languageData.wysiwygTranslation
wysiwygTranslation: languageData.wysiwygTranslation,
direction: languageData.direction || null
});
}

Expand Down
1 change: 1 addition & 0 deletions app/config/AST.app.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const AstAppConfig = {
appTheme: 'system',
language: 'en-gb',
languageType: 'default',
languageDirection: 'ltr',
enableAdvancedPreview: false,
editorFontSize: 18,
editorFontFamily: 'sans-serif',
Expand Down
9 changes: 9 additions & 0 deletions app/default-files/default-languages/fa-ir/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "فارسی",
"version": "0.0.1",
"author": "Abbas Davarpanah",
"publiiSupport": "0.46.3",
"momentLocale": "fa",
"wysiwygTranslation": false,
"direction": "rtl"
}
32 changes: 32 additions & 0 deletions app/default-files/default-languages/fa-ir/thumbnail.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading