Skip to content

Commit 3c02987

Browse files
committed
feat: add i18n script & update replace-string
1 parent f3f8d6f commit 3c02987

2 files changed

Lines changed: 44 additions & 11 deletions

File tree

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
"zip": "env-cmd -f ./.env node ./release/zip.cjs",
2121
"create:release": "env-cmd -f ./.env node ./release/create-release.cjs",
2222
"sync:version": "wp-update-project-version -s package.json -p plugin.php",
23-
"replace-string": "node ./replace-string.cjs"
23+
"replace-string": "node ./replace-string.cjs",
24+
"i18n": "wp i18n make-pot . languages/wp_refine_plugin.pot",
25+
"i18n:commit": "yarn i18n && git add . && git commit --amend --no-edit"
2426
},
2527
"dependencies": {
2628
"@refinedev/antd": "^5.37.5",
@@ -82,4 +84,4 @@
8284
"yarn-upgrade-all": "^0.7.2"
8385
},
8486
"bin": "./bin/create.cjs"
85-
}
87+
}

replace-string.cjs

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function replaceString(str) {
3737
replace.sync({
3838
files: [
3939
'./plugin.php',
40-
'./inc/class/admin/class-cpt.php',
40+
'./inc/classes/Admin/CPT.php',
4141
'./js/src/utils/env.tsx',
4242
],
4343
from: /My Refine App/g,
@@ -47,7 +47,7 @@ function replaceString(str) {
4747
replace.sync({
4848
files: [
4949
'./plugin.php',
50-
'./inc/class/admin/class-cpt.php',
50+
'./inc/classes/Admin/CPT.php',
5151
'./js/src/utils/env.tsx',
5252
],
5353
from: /my-refine-app/g,
@@ -57,7 +57,9 @@ function replaceString(str) {
5757
replace.sync({
5858
files: [
5959
'./plugin.php',
60-
'./inc/class/utils/class-base.php',
60+
'./inc/classes/Utils/Base.php',
61+
'./inc/classes/Admin/CPT.php',
62+
'./inc/classes/FrontEnd/Entry.php',
6163
'./inc/templates/test.php',
6264
'./js/src/utils/env.tsx',
6365
],
@@ -69,10 +71,10 @@ function replaceString(str) {
6971
files: [
7072
'./composer.json',
7173
'./plugin.php',
72-
'./inc/class/class-bootstrap.php',
73-
'./inc/class/admin/class-cpt.php',
74-
'./inc/class/front-end/class-entry.php',
75-
'./inc/class/utils/class-base.php',
74+
'./inc/classes/Bootstrap.php',
75+
'./inc/classes/Admin/CPT.php',
76+
'./inc/classes/FrontEnd/Entry.php',
77+
'./inc/classes/Utils/Base.php',
7678
],
7779
from: /WpRefinePlugin/g,
7880
to: pascalName,
@@ -83,15 +85,40 @@ function replaceString(str) {
8385
'./composer.json',
8486
'./package.json',
8587
'./plugin.php',
88+
'./release/.release-it.cjs',
8689
],
8790
from: /wp-refine-plugin/g,
8891
to: kebabName,
8992
})
9093

94+
replace.sync({
95+
files: [
96+
'./package.json',
97+
],
98+
from: /create-wp-refine-plugin/g,
99+
to: kebabName,
100+
})
101+
102+
replace.sync({
103+
files: [
104+
'./package.json',
105+
],
106+
from: "wp i18n make-pot . languages/wp_refine_plugin.pot",
107+
to: `wp i18n make-pot . languages/${snakeName}.pot`,
108+
})
109+
110+
replace.sync({
111+
files: [
112+
'./package.json',
113+
],
114+
from: /"version": "[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2}"/,
115+
to: '"version": "0.0.1"',
116+
})
117+
91118
replace.sync({
92119
files: [
93120
'./plugin.php',
94-
'./inc/class/admin/class-cpt.php',
121+
'./inc/classes/Admin/CPT.php',
95122
],
96123
from: /wp_refine_plugin/g,
97124
to: snakeName,
@@ -124,9 +151,13 @@ function replaceString(str) {
124151
from: '* Author: J7',
125152
to: '* Author: Your Name',
126153
},
154+
{
155+
from: "'app_name' => 'My Refine App'",
156+
to: `'app_name' => '${str}'`,
157+
},
127158
{
128159
from: 'https://github.com/j7-dev',
129-
to: 'Author URL',
160+
to: '[YOUR GITHUB URL]',
130161
},
131162
]
132163

0 commit comments

Comments
 (0)