No ke aha ʻaʻole hiki iaʻu ke holo i kaʻu polokalamu holoʻokoʻa a paena paha ma o Google Translate a loaʻa iaʻu kahi unuhi kumu ma ka ʻōlelo ʻē aʻe?
I kēia manawa, hiki iā ʻoe!
ʻO ka inoa hokeylization
' he portmanteau, ʻo ia hoʻi 'hokey localization'
He ʻano hokey no ka mea maʻalahi loa: hoʻouna i nā kaula i ka Unuhi Google
A he maʻalahi, akā ikaika loa. Loaʻa iā ia ke kākoʻo kūikawā no nā palapala HTML, HandlebarsJS, a me Markdown waihona.
Hiki iā ʻoe ke unuhi:
- he mea JavaScript me nā memo
- kekahi helu o nā faila a i ʻole nā papa kuhikuhi, e hele mau ana i nā papa kuhikuhi me ka recursively
Ua unuhi ʻia kēia palapala README.md, me ka hoʻohana ʻana i ka mea hana hokeylization ponoʻī, i loko kākoʻo ʻia kēlā me kēia ʻōlelo e ka Unuhi Google!
Ua maopopo iaʻu ʻaʻole ia i hemolele, akā manaʻo wau ʻoi aku ka maikaʻi ma mua o ka ʻole!
🇸🇦 ʻAlapia 🇧🇩 Bengali 🇩🇪 Kelemānia 🇺🇸 Pelekania 🇪🇸 Paniolo 🇫🇷 Palani 🇹🇩 Hausa 🇮🇳 Hindi 🇮🇩 Indonesia 🇮🇹 Italia 🇯🇵 Kepani 🇰🇷 Korean 🇮🇳 Marathi 🇵🇱 Polani 🇧🇷 Pukiki 🇷🇺 Lūkia 🇰🇪 Swahili 🇵🇭 Tagalog 🇹🇷 Turkish 🇵🇰 Urdu 🇻🇳 Vietnamese 🇨🇳 Pākē
ʻO kēia unuhi kikoʻī o ka [README] kumu (https://github.com/cobbzilla/hokeylization/blob/master/README.md) he hemahema paha -- * mahalo nui ʻia nā hoʻoponopono!* E ʻoluʻolu e hoʻouna i noi huki ma GitHub, a i ʻole ʻoluʻolu ʻoe e hana pēlā, wehe i kahi pilikia
Ke hana ʻoe i kahi pilikia GitHub hou e pili ana i kahi unuhi, e ʻoluʻolu e hana:
- hoʻokomo i ka URL o ka ʻaoʻao (kope/paʻi mai ka ʻaoʻao ʻaoʻao pūnaewele)
- hoʻokomo i ka kikokikona pololei i hewa (kope/paʻi mai ka polokalamu kele pūnaewele)
- ʻoluʻolu e wehewehe i ka hewa -- hewa ka unuhi? Ua haki paha ke ʻano o ke ʻano?
- ʻoluʻolu e hāʻawi i ka manaʻo o kahi unuhi ʻoi aku ka maikaʻi, a i ʻole pehea e hoʻopili pono ʻia ai ka kikokikona
- Mahalo!
- Source
- Kōkoʻo a me ke kālā
- Hoʻokomo
- Hoʻonohonoho
- Unuhi i ka waihona kumu waiwai JavaScript
- Unuhi i ka papa kuhikuhi o nā waihona kikokikona
- Nā koho ʻē aʻe
- Nā kauoha pūʻulu JSON
Ke hoʻāʻo nei au e lilo i mea hoʻomohala polokalamu open source. Ua hana au i loko ka ʻoihana polokalamu no nā makahiki he nui, ua hoʻomaka wau i nā hui kūleʻa a kūʻai aku iā lākou i nā hui lehulehu. I kēia mau lā ua nalowale kaʻu hana, a ʻaʻohe aʻu hana ʻē aʻe i laina
No laila e hoʻāʻo wau e kākau i nā polokalamu kōkua a ʻike inā pono ia
Inā hauʻoli ʻoe i ka hoʻohana ʻana i kēia polokalamu, hauʻoli wau i ka loaʻa ʻana o ka liʻiliʻi loa koʻikoʻi o kēlā me kēia mahina ma o Patreon
Mahalo!
No ka hoʻohana ʻana i ka mea hana laina kauoha, e hoʻokomo me ka hoʻohana ʻana i ka npm
a yarn
:
npm install -g hokeylization
yarn global add hokeylization
No ka hoʻohana ʻana ma ke ʻano he waihona, e hoʻokomo i ka mana lite
, ʻoi aku ka liʻiliʻi:
npm install -g hokeylization-lite
yarn global add hokeylization-lite
A laila e nānā i ke kōkua no ke kauoha hokey
:
hokey --help
hokey -h
Makemake ʻoe e ʻike i nā huahana ma kāu ʻōlelo a i ʻole kekahi ʻōlelo ʻē aʻe?
hokey
i ka ʻōlelo mai nā ʻano hoʻololi kaiapuni o kāu pūpū
Hiki iā ʻoe ke hoʻoikaika i ka ʻōlelo ma ka hoʻonohonoho ʻana i ka ʻano hoʻololi kaiapuni LC_ALL
:
LC_ALL=it hokey --help
E hoʻomaopopo inā ua hoʻokomo ʻoe i ka hokeylization-lite
, loaʻa ke kōkua kauoha ma ka ʻōlelo Pelekania wale nō
E hoʻopaʻa i ka hoʻololi kaiapuni ʻo GOOGLE_TRANSLATE_PROJECT_ID
e ʻike i kāu papahana Unuhi Google
E hoʻonoho i ka loli kaiapuni GOOGLE_APPLICATION_CREDENTIALS
i nā hōʻoia JSON āu i hoʻoiho ai
ma hope o ka noʻonoʻo ʻana pehea e hana ai ka hōʻoia ʻana ma ke ao Google (hiki ke leʻaleʻa)
Inā e holo ana ʻoe mai ke code kumu, hiki iā ʻoe ke hoʻokomo i kēia i loko o kahi faila .env
ma ke kumu
papa kuhikuhi e hoʻouka ʻia lākou i ka wā holo ma o dotenv
Aia kāu papa string pono ma kahi waihona JavaScript ma kekahi o kēia mau ʻano ʻelua:
ES6 lawe aku:
export default {
string_key: "some value",
another_key: "another value",
... more keys ...
}
CommonJS export
module.exports = {
string_key: "some value",
another_key: "another value",
... more keys ...
}
Inā kapa ʻia kēia faila myfile.en.js
, hiki iā ʻoe ke unuhi i ka ʻōlelo Paniolo a me Kelemānia me:
hokey -l es,de -o myfile.LANG.js myfile.en.js
He mea kūikawā ka LANG
ma luna -- he huaʻōlelo i mālama ʻia ma kēia mea hana!
Hoʻololi ʻia ka LANG
me ke code ʻōlelo no nā faila hoʻopuka
No laila ke kauoha i luna e hana i nā faila:
myfile.es.js
myfile.de.js
ʻO ke -l
/ --languages
he papa inoa i hoʻokaʻawale ʻia nā koma o nā code ʻōlelo ISO.
kākoʻo ʻia e ka Unuhi Google
Inā loaʻa ka faila hoʻopuka, e nānā ʻia e hoʻoholo i nā kī i loaʻa. ʻAʻole unuhi ʻia nā kī e kū nei. E hana ʻia a hoʻohui ʻia nā unuhi no nā kī nalo i ka hopena o ka mea JS. Kākau hou ʻia ka faila holoʻokoʻa.
No ka hoʻoikaika i ka unuhi hou ʻana i nā kī āpau, e hoʻohana i ke -f
/ --force
Hiki iā ʻoe ke unuhi i kahi papa kuhikuhi o nā faila. hokeylization e recursively kipa kela a me keia waihona i loko o ka papa kuhikuhi a holo i kāna mau mea ma o Google Translate, a mālama i ka hopena i kahi faila i kapa ʻia ma kahi lāʻau papa kuhikuhi kaʻawale
Inā he papa kuhikuhi ka pahuhopu o kāu unuhi, ua hoʻohana ʻia kēia ʻano
ʻO ke -o
/ --outfile
e kuhikuhi i ka papa kuhikuhi puka
NĀ MEA NUI: I ka unuhi ʻana i nā papa kuhikuhi, ** ʻAʻole ** e kuhikuhi i kahi papa kuhikuhi puka aia i loko o kāu papa kuhikuhi hoʻokomo! Inā ʻoe e hana i kēia, e:
- hoʻoulu i ka recursion pau ʻole
- hoʻopau i kāu bila Google
- hoʻopiha i kāu disk
- emi mai ka leʻaleʻa
Eia kahi laʻana o ka mea * ʻaʻole e hana *:
hokey -l es -o templates/es templates # <--- DON'T DO THIS!
Ke holo kēia, kākau ʻia nā faila i unuhi ʻia i templates/es
, a pēlā e lilo ai i mea hou
nā waihona kumu no ka unuhi ʻana, no ka mea aia lākou ma lalo o templates/
-- hoʻomau kēia kaʻina hana
mau loa, mai hana oe!
ʻAe, e ʻōlelo kākou he mau leka uila kāu ma kahi papa kuhikuhi:
templates/email/en/welcome.txt
templates/email/en/welcome.html
templates/email/en/verify-account.txt
templates/email/en/verify-account.html
templates/email/en/reset-password.txt
templates/email/en/reset-password.html
No ka unuhi ʻana i kēia mau mea a pau i ka Spanish a me ka Kelemānia, holo:
hokey -l es,de -o templates/email/LANG templates/email/en
Ma ka ʻōlelo ma luna, LANG
kahi huaʻōlelo i mālama ʻia a e pani ʻia me ke code ʻōlelo ISO
He aha ka hana i ka wā e holo ai ka mea i luna:
- E hana ʻia nā
templates/email/es
a metemplates/email/de
(inā ʻaʻole lākou) - E unuhi ʻia kēlā me kēia faila i ka
templates/email/en
Paniolo a me Kelemānia - ʻAʻole e hana hou ʻia nā faila e kū nei ke ʻole ʻoe e hoʻohana i ka
-f
/--force
- E hoʻopau ʻoe i kahi ʻano papa kuhikuhi like a me nā faila i loko o
es
a mede
e like me kāu ma lalo oen
E hele -n
/ --dry-run
e hōʻike i ka mea e hana ʻia, akā mai hana maoli i kekahi kelepona API a kākau paha i nā faila.
E -f
/ --force
no ka hana hou ʻana i nā unuhi, ʻoiai inā e loaʻa ana
E hele -m
/ --match
e kaupalena i nā faila i ka wā e holo ana ma ke ʻano papa kuhikuhi.
ʻAʻole paha ʻoe makemake e unuhi i nā faila i kēlā me kēia i kāu papa kuhikuhi kumu i kāu papa kuhikuhi
ʻO ka waiwai o ke -m
/ --match
he regex (e makaʻala i nā lula e ʻōlelo ana i ka shell!)
he aha nā faila pono e unuhi ʻia
Inā kānalua, hiki iā ʻoe ke hoʻohui i kēia koho me -n
/ --dry-run
e ʻike i nā faila e unuhi ʻia.
I kekahi manawa, pili kāu -m
' i nā faila he nui loa. E hoʻohana i ke -e
/ --excludes
e haʻalele maopopo
nā faila i like ʻole
Hiki iā ʻoe ke papa inoa i nā regex he nui, i hoʻokaʻawale ʻia e nā hakahaka
ʻO kahi hoʻohana maʻamau: --excludes node_modules dist \.git build tmp
Loaʻa paha i nā kaula e unuhi i nā {{ handlebars }}
, me ʻelua a ʻekolu paha pale pale
ʻAʻole paha ʻoe makemake e unuhi ʻia nā mea i loko o ia mau hiʻohiʻona
E hele i ka -H
/ --handlebars
, a ʻaʻole unuhi ʻia kekahi mea i loko o {{ ... }}
ʻAʻole ʻo Markdown he kikokikona a ʻaʻole html, no laila ua pilikia ka Unuhi Google me ia
Hiki i ka -M
/ --markdown
ke lawelawe kūikawā no nā faila markdown
Me nā faila markdown, inā ʻaʻole ʻoe e hoʻohana i ka hae -M
, e ʻike paha ʻoe i kēia mau pilikia:
- Nā loulou haki. Ma ka unuhi, ʻike ʻia kahi ʻano kikoʻī ma hope o ka pau ʻana o ka wehewehe ʻana i ka loulou markdown (me
]
) akā ma mua o ka hoʻomaka ʻana o kāna loulou (me ka(
). ua haki ke nānā ʻana i ka palapala. - Unuhi ʻia nā poloka code. ʻAʻole ʻike ʻo Google Unuhi i ka manaʻo o ka markdown i ke code a me ka mea ʻaʻole
- ʻAʻohe kaawale no nā poloka code indented. He mea paʻakikī ke mālama ʻana i ka hakahaka ma ka unuhi
- E unuhi ʻia nā mea i loko o ka
backticks
', ke makemake mau ʻoe iā lākou he waiwai maoli
Ke hoʻohana ʻia ka hae -M
/ --markdown
:
- E hoʻopili ʻia ke kumu
](
i](
pēlā e hoʻoponopono ai i nā loulou i haki ʻia. - E kau ʻia kahi ʻōwili "ʻaʻole unuhi" a puni nā poloka code indented, e mālama ana i ka hoʻopono kūpono a me ka hōʻoia ʻana ʻaʻole i unuhi ʻia.
- E kau ʻia kahi ʻōwili "ʻaʻole unuhi" a puni ka kikokikona i loko o nā
backticks
e hōʻoia i ka unuhi ʻole ʻia.
Hana ʻia nā mea a pau ma ke ʻano he kikokikona maʻamau
Inā he HTML kāu ʻike, e ʻāhewa ʻia ke ʻole ʻoe e hāʻawi i ke -p html
/ --process-as html
No ka mea ʻoluʻolu: i ka wā e hoʻoili ai i nā faila i kahi papa kuhikuhi, hiki iā ʻoe ke hāʻawi i ke -F
/ --filter
e kānana i ka mea hoʻopuka ma mua o ka kākau ʻia ʻana i ka waihona waihona
Pono ka waiwai o kēia koho he ala i kahi faila JS e hoʻokuʻu aku i kahi hana i kapa filter
Pono ka hana async
filter
ka mea, e kāhea ʻia ʻo await
'
Ma mua o ka kākau ʻia ʻana o nā faila i ka diski, e hāʻawi ʻia nā ʻike āpau āpau i ka hana filter
ma ke ʻano he kaula
ʻO ka waiwai hoʻihoʻi mai ka hana filter
ka mea e kākau maoli ʻia i kahi waihona
No laila, loaʻa iā ʻoe ka mana piha ma luna o ka mea e kākau hope ʻia
E ʻimi ʻia ka palapala filter
ma kēia mau wahi (me ka .js
e hoʻopili ʻia i ka kānana
inoa, ke ʻole e pau i ka .js
)
- ʻO ka papa kuhikuhi o kēia manawa
- He papa kuhikuhi i kapa
.hokey-filters
i loko o ka papa kuhikuhi o kēia manawa - He papa kuhikuhi i kapa
${HOME}/.hokey-filters
, kahi${HOME}
ka papa kuhikuhi home o ka mea hoʻohana i kēia manawa - ʻO ka [papa kuhikuhi kānana] i kūkulu ʻia (https://github.com/cobbzilla/hokeylization/tree/master/util/filter)
Hiki i ke kaula filter
he mau hua'ōlelo. I kēia hihia, ʻo ka huaʻōlelo mua ka inoa kānana, a
e hāʻawi ʻia nā huaʻōlelo i koe ma ke ʻano he hoʻopaʻapaʻa no ka hana filter
E hoʻohana -h
/ --help
e hōʻike i ke kōkua
Me ke -j
/ --json
, hiki iā ʻoe ke holo i nā kauoha hokey
i hui pū ʻia.
Ma ka convention ua kapa ʻia kēia faila hokey.json
, akā hiki iā ʻoe ke kapa inoa i nā mea āu e makemake ai
Inā hāʻawi ʻoe i kahi papa kuhikuhi ma ke -j
koho hokey
, e ʻimi ʻo hokey
i kahi hokey.json
ma ia papa kuhikuhi.
Pono ka waihona JSON i hoʻokahi mea. I loko o ia mea, ua like kona inoa waiwai me
nā koho laina kauoha, a me hoʻokahi waiwai hou i kapa hokey
ʻO ka waiwai hokey
' he pūʻulu o nā kauoha e holo. ʻO nā waiwai i haʻi ʻia i loko o kēia mau kauoha
hoʻopau i nā ʻōlelo hoʻolaha pālua i ka mea i waho.
I loko o kēlā me kēia mea i ka hokey
array, pono ʻoe e kuhikuhi i kahi name
, a me nā faila komo a me nā faila.
Eia kekahi laʻana o ka hokey.json
{
"inputLanguage": "en",
"languages": "es,fr,ja", # can also be an array of strings
"force": false,
"match": null,
"processAs": null,
"excludes": ["exclude-1", "exclude-2"],
"handlebars": false,
"markdown": false,
"regular": false,
"dryRun": false,
"filter": "theFilter.js",
"hokey": [
{
"name": "locale names",
"infile": "messages/locales_en.js",
"outfile": "messages/locales_LANG.js",
"handlebars": true
},
{
"name": "CLI messages",
"infile": "messages/en_messages.js",
"outfile": "messages/LANG_messages.js",
"handlebars": true
},
{
"name": "README",
"infile": "README.md",
"outfile": "lang/LANG/",
"excludes": ["lang/", "node_modules/", "\\.git/", "tmp/"],
"filter": "relativizeMarkdownLinks lang",
"markdown": true,
"index": "lang/README.md"
}
]
}
Hāʻawi i kahi ʻano o nā ala faila ma ke ʻano he infiles
ma kahi o kahi ala hoʻokahi infile
, e like me kēia hiʻohiʻona:
{
... [
{
"name": "my docs",
"infiles": ["README.md", "INSTALL.md", "TUTORIAL.md"],
"outfile": "docs/LANG/",
"markdown": true
]
}
I ka unuhi ʻana i nā ʻōlelo he nui, hiki i ka hokey
ke hana i kahi faila kuhikuhi e papa inoa i nā unuhi āpau i hana ʻia.
a hāʻawi i nā loulou iā lākou
I ka hana ʻana i nā kuhikuhi, hiki iā ʻoe ke loaʻa hoʻokahi kumu hoʻokomo wale nō
E hāʻawi i ke koho -I
/ --index
, ʻo ka waiwai kahi e hana ʻia ai ka faila kuhikuhi, hiki ke lilo i faila.
a i ʻole he papa kuhikuhi. Inā he papa kuhikuhi, e hoʻohana ʻia kahi inoa file paʻamau, e pili ana i ka template (e ʻike i lalo)
E hoʻohana i ka -A
/ --index-template
no ka hoʻoholo ʻana i ke ʻano o ka hoʻohālikelike ʻia ʻana o ka huaʻōlelo kuhikuhi. Hiki iā ʻoe ke kuhikuhi 'html',
'markdown', 'text', a i ʻole ke ala waihona i kāu HandlebarsJS template
Inā ʻoe e kuhikuhi i kāu hoʻohālike ponoʻī, pono ʻoe e kuhikuhi i kahi faila (ʻaʻole he papa kuhikuhi) no ka -I
/ --index
koho