This repository has been archived by the owner on Dec 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 272
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: properly translate the table chart (#724)
- Loading branch information
Showing
19 changed files
with
512 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
const logger = window.console || { | ||
debug() {}, | ||
log() {}, | ||
info() {}, | ||
warn() {}, | ||
error() {}, | ||
trace() {}, | ||
}; | ||
|
||
/** | ||
* Superset frontend logger, currently just an alias to console. | ||
*/ | ||
export default logger; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* eslint-disable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call */ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
describe('logging', () => { | ||
beforeEach(() => { | ||
jest.resetModules(); | ||
}); | ||
it('should pipe to `console` methods', () => { | ||
const { logging } = require('../../src'); | ||
|
||
expect(() => { | ||
logging.debug(); | ||
logging.log(); | ||
logging.info(); | ||
}).not.toThrow(); | ||
expect(() => { | ||
logging.warn('warn'); | ||
}).toThrow('warn'); | ||
expect(() => { | ||
logging.error('error'); | ||
}).toThrow('error'); | ||
expect(() => { | ||
logging.trace(); | ||
}).toThrow('Trace:'); | ||
}); | ||
it('should use noop functions when console unavailable', () => { | ||
const { console } = window; | ||
Object.assign(window, { console: undefined }); | ||
const { logging } = require('../../src'); | ||
|
||
afterAll(() => { | ||
Object.assign(window, { console }); | ||
}); | ||
|
||
expect(() => { | ||
logging.debug(); | ||
logging.log(); | ||
logging.info(); | ||
logging.warn('warn'); | ||
logging.error('error'); | ||
logging.trace(); | ||
}).not.toThrow(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export { configure, t, tn } from './TranslatorSingleton'; | ||
export * from './TranslatorSingleton'; | ||
export * from './types'; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
import { Jed as BaseJed, JedOptions, DomainData, Translations } from './jed'; | ||
|
||
export { Translations } from './jed'; | ||
|
||
/** | ||
* Superset supported languages. | ||
*/ | ||
export type Locale = 'de' | 'en' | 'es' | 'fr' | 'it' | 'ja' | 'ko' | 'pt' | 'pt_BR' | 'ru' | 'zh'; // supported locales in Superset | ||
|
||
/** | ||
* Language pack provided to `jed`. | ||
*/ | ||
export type LanguagePack = JedOptions & { | ||
// eslint-disable-next-line camelcase | ||
locale_data: { | ||
superset: DomainData & { | ||
'': { | ||
domain: 'superset'; | ||
lang: Locale; | ||
// eslint-disable-next-line camelcase | ||
plural_forms: string; | ||
}; | ||
}; | ||
}; | ||
}; | ||
|
||
export interface Jed extends BaseJed { | ||
options: LanguagePack; | ||
} | ||
|
||
/** | ||
* Config options for Translator class. | ||
*/ | ||
export interface TranslatorConfig { | ||
languagePack?: LanguagePack; | ||
} | ||
|
||
/** | ||
* Key-value mapping of translation key and the translations. | ||
*/ | ||
export type LocaleData = Partial<Record<Locale, Translations>>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* Translations for a language in the format of { key: [singular, plural, ...]}. | ||
*/ | ||
export type Translations = { | ||
[key: string]: ReadonlyArray<string>; | ||
}; | ||
|
||
export interface DomainConfig { | ||
domain: string; | ||
lang: string; | ||
// eslint-disable-next-line camelcase | ||
plural_forms: string; | ||
} | ||
|
||
export type DomainData = { '': DomainConfig } & { | ||
[key: string]: ReadonlyArray<string> | DomainConfig; | ||
}; | ||
|
||
export interface JedOptions { | ||
domain: string; | ||
// eslint-disable-next-line camelcase | ||
locale_data: { | ||
[domain: string]: DomainData; | ||
}; | ||
} | ||
|
||
export interface Jed { | ||
translate(input: string): Jed; | ||
|
||
ifPlural(value: number, plural: string): Jed; | ||
|
||
fetch(...args: unknown[]): string; | ||
|
||
options: JedOptions; | ||
} |
Oops, something went wrong.
ffa6445
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: