-
Notifications
You must be signed in to change notification settings - Fork 993
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #17263 - move jed (i18n) to webpack
- Loading branch information
Showing
45 changed files
with
149 additions
and
59 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
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,7 +1,7 @@ | ||
providerSpecificNICInfo = function(form) { | ||
if (form.find('select.libvirt_network').val() == 'network') { | ||
return Jed.sprintf(__('physical @ NAT %s'), form.find('select.libvirt_nat').val()); | ||
return tfm.i18n.sprintf(__('physical @ NAT %s'), form.find('select.libvirt_nat').val()); | ||
} else { | ||
return Jed.sprintf(__('physical @ bridge %s'), form.find('select.libvirt_bridge').val()); | ||
return tfm.i18n.sprintf(__('physical @ bridge %s'), form.find('select.libvirt_bridge').val()); | ||
} | ||
} |
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 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
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
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
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,30 @@ | ||
import Jed from 'jed'; | ||
import { deprecateObjectProperty } from '../../foreman_tools'; | ||
|
||
const cheveronPrefix = () => (window.I18N_MARK ? '\u00BB' : ''); | ||
const cheveronSuffix = () => (window.I18N_MARK ? '\u00AB' : ''); | ||
|
||
const emptyLocales = { | ||
en: { domain: 'app', locale_data: { app: { '': {} } } }, | ||
}; | ||
|
||
const locales = window.locales || emptyLocales; | ||
let locale = document.getElementsByTagName('html')[0].lang; | ||
|
||
locale = locale.length === 0 ? 'en' : locale.replace(/-/g, '_'); | ||
export const jed = new Jed(locales[locale]); | ||
|
||
export const translate = (...args) => `${cheveronPrefix()}${jed.gettext(...args)}${cheveronSuffix()}`; | ||
export const ngettext = (...args) => `${cheveronPrefix()}${jed.ngettext(...args)}${cheveronSuffix()}`; | ||
|
||
export const { sprintf } = jed; | ||
|
||
const i18n = { translate, ngettext, jed }; | ||
export default i18n; | ||
window.__ = translate; | ||
window.n__ = ngettext; | ||
window.Jed = jed; | ||
window.i18n = jed; | ||
|
||
deprecateObjectProperty(window, 'i18n', 'tfm.i18n'); | ||
deprecateObjectProperty(window, 'Jed', 'tfm.i18n.jed'); |
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,27 @@ | ||
import Jed from 'jed'; | ||
import { translate, ngettext } from './I18n'; | ||
|
||
jest.unmock('./I18n'); | ||
jest.unmock('jed'); | ||
|
||
describe('gettext', () => { | ||
Jed.gettext = jest.fn(s => s); | ||
it('chevrons should not be presented', () => { | ||
expect(translate('should not be with chevrons')).toMatchSnapshot(); | ||
}); | ||
it('chevrons should be presented', () => { | ||
global.I18N_MARK = true; | ||
expect(translate('should be with chevrons')).toMatchSnapshot(); | ||
}); | ||
}); | ||
|
||
describe('ngettext', () => { | ||
Jed.ngettext = jest.fn(s => s); | ||
it('chevrons should not be presented', () => { | ||
expect(ngettext('should not be with chevrons')).toMatchSnapshot(); | ||
}); | ||
it('chevrons should be presented', () => { | ||
global.I18N_MARK = true; | ||
expect(ngettext('should be with chevrons')).toMatchSnapshot(); | ||
}); | ||
}); |
9 changes: 9 additions & 0 deletions
9
webpack/assets/javascripts/react_app/common/__snapshots__/I18n.test.js.snap
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,9 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`gettext chevrons should be presented 1`] = `"»should be with chevrons«"`; | ||
|
||
exports[`gettext chevrons should not be presented 1`] = `"should not be with chevrons"`; | ||
|
||
exports[`ngettext chevrons should be presented 1`] = `"»should be with chevrons«"`; | ||
|
||
exports[`ngettext chevrons should not be presented 1`] = `"»should not be with chevrons«"`; |
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
2 changes: 2 additions & 0 deletions
2
...ack/assets/javascripts/react_app/components/PasswordStrength/PasswordStrength.fixtures.js
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
2 changes: 1 addition & 1 deletion
2
webpack/assets/javascripts/react_app/components/PasswordStrength/PasswordStrength.js
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
1 change: 1 addition & 0 deletions
1
webpack/assets/javascripts/react_app/components/bookmarks/SearchModal.js
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
Oops, something went wrong.