Skip to content

Commit

Permalink
Improve Chinese Language Support & Fix Issue with Asset File Names (l…
Browse files Browse the repository at this point in the history
…exiconhq#47)

* fix assets name

* fix getting poster ditails for different language

---------

Co-authored-by: jinqi.wei <[email protected]>
  • Loading branch information
Bardreamaster and jinqi.wei committed Nov 29, 2023
1 parent c0f918d commit b66b3a8
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 3 deletions.
34 changes: 33 additions & 1 deletion api/src/__tests__/getPosterTypeDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,39 @@ describe('getPosterTypeDetails', () => {
});
});
});
describe('Chinese', () => {
describe('Simplified Chinese', () => {
it('handles a string where original poster is not first', () => {
const result = getPosterTypeDetails('频繁发帖人、原始发帖人');

expect(result).toEqual({
isAuthor: true,
isFrequentPoster: true,
isMostRecentPoster: false,
});
});

it('handles all three types', () => {
const result = getPosterTypeDetails(
'原始发帖人、 最新发帖人、 频繁发帖人',
);
expect(result).toEqual({
isAuthor: true,
isFrequentPoster: true,
isMostRecentPoster: true,
});
});
it('handles multiple spaces between entries', () => {
const result = getPosterTypeDetails(
' 原始发帖人、 最新发帖人、 频繁发帖人 ',
);
expect(result).toEqual({
isAuthor: true,
isFrequentPoster: true,
isMostRecentPoster: true,
});
});
});
describe('Traditional Chinese', () => {
it('handles a string where original poster is not first', () => {
const result = getPosterTypeDetails('頻繁發文者、原始作者');

Expand Down
17 changes: 15 additions & 2 deletions api/src/locale/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from '../types';

// source: github.com:discourse/discourse -> config/locales/server.en.yml
// source: github.com:discourse/discourse -> config/locales/server.zh_TW.yml
// source: github.com:discourse/discourse -> config/locales/server.zh_CN.yml
// key: `poster_description_joiner`
export const i18nSeparatorsRegex = /,|、/;

Expand All @@ -17,8 +17,19 @@ const i18nPosterTypes = {
'most recent poster': MostRecentPoster.value,
'frequent poster': FrequentPoster.value,
},
// source: github.com:discourse/discourse -> config/locales/server.zh_TW.yml
// source: github.com:discourse/discourse -> config/locales/server.zh_CN.yml
zh: {
原始发帖人: OriginalPoster.value,
最新发帖人: MostRecentPoster.value,
频繁发帖人: FrequentPoster.value,
},
zh_cn: {
原始发帖人: OriginalPoster.value,
最新发帖人: MostRecentPoster.value,
频繁发帖人: FrequentPoster.value,
},
// source: github.com:discourse/discourse -> config/locales/server.zh_TW.yml
zh_tw: {
原始作者: OriginalPoster.value,
當前大部分貼文作者: MostRecentPoster.value,
頻繁發文者: FrequentPoster.value,
Expand All @@ -28,6 +39,8 @@ const i18nPosterTypes = {
const posterTypeMap: Record<string, PosterType> = {
...i18nPosterTypes.en,
...i18nPosterTypes.zh,
...i18nPosterTypes.zh_cn,
...i18nPosterTypes.zh_tw,
};

export const getPosterType = (type: string): PosterType | undefined => {
Expand Down

0 comments on commit b66b3a8

Please sign in to comment.