-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move localizeUrl to new i18n-utils package (#46998)
Co-authored-by: Philip Jackson <[email protected]>
- Loading branch information
Showing
14 changed files
with
694 additions
and
504 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module.exports = { | ||
overrides: [ | ||
{ | ||
files: [ '*.md.js' ], | ||
rules: { | ||
'import/no-extraneous-dependencies': 'off', | ||
}, | ||
}, | ||
], | ||
}; |
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 @@ | ||
# I18n Utils | ||
|
||
I18n-related utilities for use by client, server, apps, and packages. | ||
|
||
## Usage | ||
|
||
```js | ||
import { localizeUrl } from '@automattic/i18n-utils'; | ||
``` |
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,3 @@ | ||
module.exports = { | ||
preset: '../../test/packages/jest-preset.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"name": "@automattic/i18n-utils", | ||
"version": "1.0.0", | ||
"description": "WordPress.com i18n utils", | ||
"main": "dist/cjs/index.js", | ||
"module": "dist/esm/index.js", | ||
"types": "dist/types/index.d.ts", | ||
"sideEffects": false, | ||
"license": "GPL-2.0-or-later", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/Automattic/wp-calypso.git", | ||
"directory": "packages/i18n-utils" | ||
}, | ||
"author": "Automattic Inc.", | ||
"scripts": { | ||
"clean": "npx rimraf dist", | ||
"prepublish": "yarn run clean", | ||
"prepare": "tsc --project ./tsconfig.json && tsc --project ./tsconfig-cjs.json", | ||
"watch": "tsc --project ./tsconfig.json --watch", | ||
"download": "node bin/download.js", | ||
"test": "yarn jest" | ||
}, | ||
"dependencies": { | ||
"i18n-calypso": "^5.0.0" | ||
} | ||
} |
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 @@ | ||
export { localizeUrl } from './localize-url'; |
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,114 @@ | ||
/** | ||
* The locale sets here map roughly to those found in locales.php | ||
* | ||
* todo: move these into @automattic/languages as another downloaded resource | ||
* todo: cleanup _shared.json - replace references to the below config options with imports from here | ||
*/ | ||
export type Locale = string; | ||
export const i18nDefaultLocaleSlug: Locale = 'en'; | ||
export const localesWithBlog: Locale[] = [ 'en', 'ja', 'es', 'pt', 'fr', 'pt-br' ]; | ||
export const localesWithPrivacyPolicy: Locale[] = [ 'en', 'fr', 'de' ]; | ||
export const localesWithCookiePolicy: Locale[] = [ 'en', 'fr', 'de' ]; | ||
|
||
type LocaleSubdomain = string; | ||
|
||
export const localesToSubdomains: Record< string, LocaleSubdomain > = { | ||
'pt-br': 'br', | ||
br: 'bre', | ||
zh: 'zh-cn', | ||
'zh-hk': 'zh-tw', | ||
'zh-sg': 'zh-cn', | ||
kr: 'ko', | ||
}; | ||
|
||
// replaces config( 'english_locales' ) | ||
export const englishLocales: Locale[] = [ 'en', 'en-gb' ]; | ||
|
||
// replaces config( 'livechat_support_locales' ) | ||
export const livechatSupportLocales: Locale[] = [ 'en', 'es', 'pt-br' ]; | ||
|
||
// replaces config( 'support_site_locales' ) | ||
export const supportSiteLocales: Locale[] = [ | ||
'ar', | ||
'de', | ||
'en', | ||
'es', | ||
'fr', | ||
'he', | ||
'id', | ||
'it', | ||
'ja', | ||
'ko', | ||
'nl', | ||
'pt-br', | ||
'ru', | ||
'sv', | ||
'tr', | ||
'zh-cn', | ||
'zh-tw', | ||
]; | ||
|
||
// replaces config( 'forum_locales') | ||
export const forumLocales: Locale[] = [ | ||
'ar', | ||
'de', | ||
'el', | ||
'en', | ||
'es', | ||
'fa', | ||
'fi', | ||
'fr', | ||
'id', | ||
'it', | ||
'ja', | ||
'nl', | ||
'pt', | ||
'pt-br', | ||
'ru', | ||
'sv', | ||
'th', | ||
'tl', | ||
'tr', | ||
]; | ||
|
||
// replaces config( 'magnificent_non_en_locales') | ||
export const magnificentNonEnLocales: Locale[] = [ | ||
'es', | ||
'pt-br', | ||
'de', | ||
'fr', | ||
'he', | ||
'ja', | ||
'it', | ||
'nl', | ||
'ru', | ||
'tr', | ||
'id', | ||
'zh-cn', | ||
'zh-tw', | ||
'ko', | ||
'ar', | ||
'sv', | ||
]; | ||
|
||
// replaces config( 'jetpack_com_locales') | ||
export const jetpackComLocales: Locale[] = [ | ||
'en', | ||
'ar', | ||
'de', | ||
'es', | ||
'fr', | ||
'he', | ||
'id', | ||
'it', | ||
'ja', | ||
'ko', | ||
'nl', | ||
'pt-br', | ||
'ro', | ||
'ru', | ||
'sv', | ||
'tr', | ||
'zh-cn', | ||
'zh-tw', | ||
]; |
Oops, something went wrong.