From dfe5598c5d1d877d2c23bdb002e89eac869f9613 Mon Sep 17 00:00:00 2001 From: elijah Date: Tue, 27 Sep 2016 12:16:43 -0700 Subject: [bug] Display language and services correctly in provider wizard --- ui/app/components/wizard/provider_select_stage.js | 13 ++++- ui/app/lib/language.js | 60 +++++++++++++++++++++++ 2 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 ui/app/lib/language.js (limited to 'ui') diff --git a/ui/app/components/wizard/provider_select_stage.js b/ui/app/components/wizard/provider_select_stage.js index 19799f8..e33310b 100644 --- a/ui/app/components/wizard/provider_select_stage.js +++ b/ui/app/components/wizard/provider_select_stage.js @@ -3,6 +3,7 @@ import {Button, ButtonGroup, ButtonToolbar, Glyphicon} from 'react-bootstrap' import App from 'app' import Provider from 'models/provider' +import Language from 'lib/language' import ListEditor from 'components/list_editor' import {HorizontalLayout, Column} from 'components/layout' @@ -10,6 +11,12 @@ import {HorizontalLayout, Column} from 'components/layout' import StageLayout from './stage_layout' import AddProviderModal from './add_provider_modal' +const SERVICE_MAP = { + mx: "Mail", + openvpn: "VPN", + chat: "Chat" +} + export default class ProviderSelectStage extends React.Component { static get defaultProps() {return{ @@ -131,14 +138,16 @@ export default class ProviderSelectStage extends React.Component { let modal = null let info = null if (this.state.provider) { + let languages = this.state.provider.languages.map(code => Language.find(code).name) + let services = this.state.provider.services.map(code => SERVICE_MAP[code] || '????') info = (

{this.state.provider.name}

{this.state.provider.domain}

{this.state.provider.description}

Enrollment Policy: {this.state.provider.enrollment_policy}

-

Services: {this.state.provider.services}

-

Languages: {this.state.provider.languages.join(', ')}

+

Services: {services}

+

Languages: {languages.join(', ')}

) } else if (this.state.error) { diff --git a/ui/app/lib/language.js b/ui/app/lib/language.js new file mode 100644 index 0000000..17e00fd --- /dev/null +++ b/ui/app/lib/language.js @@ -0,0 +1,60 @@ +// +// Language data, sorted by number of native speakers +// https://en.wikipedia.org/wiki/List_of_languages_by_number_of_native_speakers +// fields: code, name, english name, right to left? +// + +const DATA = { + zh: ['zh', '中文', 'Chinese'], + es: ['es', 'Español', 'Spanish'], + en: ['en', 'English'], + hi: ['hi', 'हिन्दी', 'Hindi'], + ar: ['ar', 'العربية', 'Arabic', true], + pt: ['pt', 'Português', 'Portugues'], + bn: ['bn', 'বাংলা', 'Bengali'], + ru: ['ru', 'Pyccĸий', 'Russian'], + ja: ['ja', '日本語', 'Japanese'], + pa: ['pa', 'ਪੰਜਾਬੀ', 'Punjabi'], + de: ['de', 'Deutsch', 'German'], + ms: ['ms', 'بهاس ملايو', 'Malay'], + te: ['te', 'తెలుగు', 'Telugu'], + vi: ['vi', 'Tiếng Việt', 'Vietnamese'], + ko: ['ko', '한국어', 'Korean'], + fr: ['fr', 'Français', 'French'], + mr: ['mr', 'मराठी', 'Marathi'], + ta: ['ta', 'தமிழ்', 'Tamil'], + ur: ['ur', 'اُردُو', 'Urdu'], + fa: ['fa', 'فارسی', 'Farsi'], + tr: ['tr', 'Türkçe', 'Turkish'], + it: ['it', 'Italiano', 'Italian'], + th: ['th', 'ภาษาไทย', 'Thai'], + gu: ['gu', 'Gujarati'], + pl: ['pl', 'Polski', 'Polish'], + ml: ['ml', 'Malayalam'], + uk: ['uk', 'Ukrainian'], + sw: ['sw', 'Swahili'], + uz: ['uz', 'Uzbek'], + ro: ['ro', 'Romanian'], + nl: ['nl', 'Nederlands', 'Dutch'], + sr: ['sr', 'Serbian'], + el: ['el', 'Ελληνικά', 'Greek'], + ca: ['ca', 'Català', 'Catalan'], + he: ['he', 'עברית', 'Hebrew', true], + sl: ['sl', 'Slovenščina', 'Slovenian'], + lt: ['lt', 'Lietuvių kalba', 'Lithuanian'] +} + +export default class Language { + + constructor(data_entry) { + this.code = data_entry[0] || 'xx' + this.name = data_entry[1] || '????' + this.en_name = data_entry[2] || '????' + this.rtl = data_entry[3] + } + + static find(code) { + return new Language(DATA[code]) + } + +} -- cgit v1.2.3