Skip to content

Commit

Permalink
Merge branch 'v1-dev-879-suggestions' of https://github.com/petkir/sp…
Browse files Browse the repository at this point in the history
…-dev-fx-controls-react into petkir-v1-dev-879-suggestions
  • Loading branch information
AJIXuMuK committed Sep 18, 2021
2 parents 3a9c87f + ece8464 commit a28f81e
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 4 deletions.
76 changes: 76 additions & 0 deletions src/common/utilities/LocalesHelper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
export class LocalesHelper {

private static locales = {
1025: 'ar-SA',
1026: 'bg-BG',
1027: 'ca-ES',
1028: 'zh-TW',
1029: 'cs-CZ',
1030: 'da-DK',
1031: 'de-DE',
1032: 'el-GR',
1033: 'en-US',
1035: 'fi-FI',
1036: 'fr-FR',
1037: 'he-IL',
1038: 'hu-HU',
1040: 'it-IT',
1041: 'ja-JP',
1042: 'ko-KR',
1043: 'nl-NL',
1044: 'nb-NO',
1045: 'pl-PL',
1046: 'pt-BR',
1048: 'ro-RO',
1049: 'ru-RU',
1050: 'hr-HR',
1051: 'sk-SK',
1053: 'sv-SE',
1054: 'th-TH',
1055: 'tr-TR',
1057: 'id-ID',
1058: 'uk-UA',
1060: 'sl-SI',
1061: 'et-EE',
1062: 'lv-LV',
1063: 'lt-LT',
1066: 'vi-VN',
1068: 'az-Latn-AZ',
1069: 'eu-ES',
1071: 'mk-MK',
1081: 'hi-IN',
1086: 'ms-MY',
1087: 'kk-KZ',
1106: 'cy-GB',
1110: 'gl-ES',
1164: 'prs-AF',
2052: 'zh-CN',
2070: 'pt-PT',
2108: 'ga-IE',
3082: 'es-ES',
5146: 'bs-Latn-BA',
9242: 'sr-Latn-RS',
10266: 'sr-Cyrl-RS',
};
public static getLocaleId(localeName: string): number {
const pos: number = (Object as any).values(this.locales).indexOf(localeName);
if (pos > -1) {
return parseInt(Object.keys(this.locales)[pos]);
}
else {
return 0;
}
}

public static getLocaleName(localeId: number): string {
const pos: number = Object.keys(this.locales).indexOf(localeId.toString());
if (pos > -1) {
return (Object as any).values(this.locales)[pos];
}
else {
return '';
}
}


}
3 changes: 2 additions & 1 deletion src/common/utilities/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './FieldRendererHelper';
export * from './GeneralHelper';
export * from './SPHelper';
export * from './SPHelper';
export * from './LocalesHelper';
6 changes: 3 additions & 3 deletions src/services/SPTermStorePickerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import SPTermStoreMockHttpClient from './SPTermStorePickerMockService';
import { findIndex } from '@microsoft/sp-lodash-subset';
import { ExtensionContext } from '@microsoft/sp-extension-base';
import { EmptyGuid } from '../common/Constants';

import { LocalesHelper } from '../common/utilities/LocalesHelper';

/**
* Service implementation to manage term stores in SharePoint
Expand Down Expand Up @@ -400,10 +400,10 @@ export default class SPTermStorePickerService {
resolve(null);
return;
}

let loc = LocalesHelper.getLocaleId(this.context.pageContext.cultureInfo.currentUICultureName);
let data = {
start: searchText,
lcid : this.context.pageContext.web.language, // TODO : get the user's navitation LCID. Here it's the default web language LCID
lcid: loc !== 0 ? loc : this.context.pageContext.web.language,
sspList: this.cleanGuid(termStore[0].Id),
termSetList: TermSetId,
anchorId: this.props.anchorId ? this.props.anchorId : EmptyGuid,
Expand Down

0 comments on commit a28f81e

Please sign in to comment.