Me ya sa ba zan iya tafiyar da dukkan manhaja ko rukunin yanar gizona ta Google Translate ba kuma in sami fassarar asali a cikin wani yare?
*** Yanzu, zaku iya! ***
Sunan hokeylization
' portmanteau ne, ma'ana 'kwayar hokey'
Yana da ɗan hokey saboda yana da sauƙi sosai: yana aika kirtani zuwa Google Translate
Kuma yana da sauƙi, amma kuma yana da ƙarfi sosai. Yana da tallafi na musamman don takaddun HTML, HandlebarsJS samfuri, da Markdown fayiloli.
Kuna iya fassara:
- Abun JavaScript mai ɗauke da saƙonni
- kowane adadin fayiloli ko kundayen adireshi, koyaushe suna bin kundayen adireshi akai-akai
An fassara wannan takaddar README.md, ta amfani da kayan aikin hokeylization kanta, zuwa cikin kowane harshe yana da tallafin Google Translate!
Na tabbata ba cikakke ba ne, amma ina fata ya fi komai kyau!
🇸🇦 Larabci 🇧🇩 Bengali 🇩🇪 Jamusanci 🇺🇸 Turanci 🇪🇸 Mutanen Espanya 🇫🇷 Faransanci 🇹🇩 Hausa 🇮🇳 Hindi 🇮🇩 Indonesian 🇮🇹 Italiyanci 🇯🇵 Jafananci 🇰🇷 Korean 🇮🇳 Marathi 🇵🇱 Yaren mutanen Poland 🇧🇷 Portuguese 🇷🇺 Rashanci 🇰🇪 Swahili 🇵🇭 Tagalog 🇹🇷 Baturke 🇵🇰 Urdu 🇻🇳 Vietnamese 🇨🇳 Sinanci
Wannan fassarar ta asali ta asali README na iya zama aibi - * ana maraba da gyare-gyare!* Da fatan za a aika buƙatun ja akan GitHub, ko kuma idan ba ku ji daɗin yin hakan ba, buɗe batun
Lokacin da kuka ƙirƙiri sabon batun GitHub game da fassarar, da fatan za a yi:
- hada da URL na shafi (kwafi / manna daga mashaya adireshin mashigin)
- hada da ainihin rubutun da ba daidai ba (kwafi / manna daga mai bincike)
- don Allah bayyana abin da ba daidai ba -- shin fassarar ba daidai ba ce? an karye tsarin ko ta yaya?
- a hankali ba da shawarar mafi kyawun fassarar, ko yadda ya kamata a tsara rubutun yadda ya kamata
- Na gode!
- Madogararsa
- Tallafawa da Kuɗi
- Shigarwa
- [Saituna](# Saita)
- Fassara fayil ɗin albarkatun kirtani na JavaScript
- Fassara kundin fayilolin rubutu
- Sauran zaɓuɓɓuka
- JSON batch umarni
Ina ƙoƙari in zama ƙwararren mai haɓaka tushen software. Na kasance ina aiki a ciki masana'antar software tsawon shekaru da yawa, na fara kamfanoni masu nasara kuma na sayar da su ga kamfanonin jama'a. Kwanan nan na rasa aiki, kuma ba ni da wani aiki a layi daya
Don haka zan gwada rubuta software mai taimako don ganin ko hakan yana aiki
Idan kuna jin daɗin amfani da wannan software, zan yi farin cikin karɓar ko da mafi ƙanƙanta gudunmawar wata-wata ta hanyar Patreon
Na gode!
Don amfani da kayan aikin layin umarni, shigar ta amfani da npm
ko yarn
:
npm install -g hokeylization
yarn global add hokeylization
Don amfani azaman ɗakin karatu, shigar da sigar lite
, wanda ya fi ƙanƙanta:
npm install -g hokeylization-lite
yarn global add hokeylization-lite
Sannan duba taimako don umarnin hokey
:
hokey --help
hokey -h
Kuna son ganin fitarwa a cikin yaren ku ko wani yare?
hokey
yana ƙoƙarin gano harshen ta atomatik daga masu canjin yanayin harsashin ku
Kuna iya tilasta harshe ta saita canjin yanayi na LC_ALL
:
LC_ALL=it hokey --help
Lura cewa idan kun shigar da hokeylization-lite
, taimakon umarni yana samuwa ne kawai cikin Turanci
Saita canjin yanayi na GOOGLE_TRANSLATE_PROJECT_ID
don gano aikin Fassara na Google
Saita canjin muhallin GOOGLE_APPLICATION_CREDENTIALS
zuwa abubuwan shaidar JSON da kuka zazzage
bayan gano yadda tantancewar ke aiki akan girgijen Google (zai iya zama abin daɗi)
Idan kuna gudana daga lambar tushe, kuna iya sanya waɗannan a cikin fayil .env
a cikin tushen
directory za a loda su a lokacin aiki ta dotenv
Teburin kirtani na ku dole ne ya kasance cikin fayil ɗin JavaScript a ɗayan waɗannan nau'ikan guda biyu:
ES6 fitarwa:
export default {
string_key: "some value",
another_key: "another value",
... more keys ...
}
CommonJS fitarwa
module.exports = {
string_key: "some value",
another_key: "another value",
... more keys ...
}
Idan sunan wannan fayil ɗin myfile.en.js
, zaku iya fassara shi zuwa Mutanen Espanya da Jamusanci tare da:
hokey -l es,de -o myfile.LANG.js myfile.en.js
LANG
a sama na musamman ne - kalma ce da aka tanada a cikin wannan kayan aikin!
An maye gurbin LANG
tare da lambar yare don fayilolin fitarwa
Don haka umarnin da ke sama yana ƙirƙirar fayilolin:
myfile.es.js
myfile.de.js
-l
/ --languages
jerin waƙafi ne na lambobin yare na ISO.
Google Translate yana tallafawa
Idan fayil ɗin fitarwa ya riga ya wanzu, za a bincika don sanin waɗanne maɓallan da suka riga sun wanzu. Ba za a fassara maɓallan da suka wanzu ba. Za a samar da fassarorin maɓallan da suka ɓace kuma a saka su har zuwa karshen abin JS. Ana sake rubuta duk fayil ɗin koyaushe.
Don tilasta sake fassara duk maɓallan, yi amfani da -f
/ --force
Hakanan zaka iya fassara kundin adireshi na fayiloli. hokeylization zai ci gaba da ziyartar kowane fayil a cikin directory kuma gudanar da abinda ke ciki ta Google Translate, da kuma ajiye fitarwa zuwa fayil mai suna iri ɗaya a cikin bishiyar jagorar daban
Lokacin da makasudin fassarar ku shine kundin adireshi, ana kunna wannan yanayin
-o
/ --outfile
ƙayyadad da tsarin fitarwa
** BABBAN GARGADI ***: Lokacin da ake fassara kundayen adireshi, **KADA *** ayyana jagorar fitarwa. wannan yana cikin kundin shigar da ku! Idan kun yi haka, za ku:
- jawo maimaitawa mara iyaka
- gudanar da lissafin Google
- cika faifan ku
- rage jin daɗi
Ga misalin abin da ba za a yi ba:
hokey -l es -o templates/es templates # <--- DON'T DO THIS!
Lokacin da wannan ke gudana, fayilolin da aka fassara ana rubuta su zuwa templates/es
, don haka su zama sababbi
tushen fayilolin da za a fassara, tunda suna ƙarƙashin templates/
-- wannan tsari yana ci gaba
har abada, kada ku yi!
Ok, bari mu ce kuna da wasu samfuran imel a cikin kundin adireshi:
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
Don fassara duk waɗannan zuwa Mutanen Espanya da Jamusanci, gudu:
hokey -l es,de -o templates/email/LANG templates/email/en
A cikin sama, LANG
ce da aka tanada kuma za a maye gurbinta da lambar yaren ISO
Abin da ke faruwa idan abin da ke sama ya gudana:
- Za a
templates/email/es
' datemplates/email/de
kundayen adireshi (idan babu su) - Kowane fayil a cikin
templates/email/en
za a fassara shi zuwa Mutanen Espanya da Jamusanci - Fayilolin fitarwa da suka wanzu ba za a sabunta su ba sai kun yi amfani da
-f
/--force
- Za ku ƙare da tsari iri ɗaya da fayiloli a cikin
es
' dade
kamar yadda kuke da shi a ƙarƙashinen
Wuce -n
/ --dry-run
don nuna abin da za a yi, amma kar a yi kowane kiran API ko rubuta kowane fayil
Wuce -f
/ --force
don sabunta fassarori koyaushe, koda kuwa sun wanzu
Wuce -m
/ --match
don iyakance fayilolin da aka sarrafa lokacin aiki a cikin yanayin shugabanci
Wataƙila ba koyaushe kuna son fassara kowane fayil a cikin tushen tushen ku zuwa kundin adireshin ku ba
Ƙimar zaɓi na -m
/ --match
regex ne (a yi hankali da ƙa'idodin faɗar harsashi!)
waɗanne fayiloli ya kamata a fassara
Lokacin da ake shakka, zaku iya haɗa wannan zaɓi tare da -n
/ --dry-run
don ganin waɗanne fayiloli za a fassara
Wani lokaci -m
dace da fayiloli da yawa. Yi amfani da -e
/ --excludes
da zaɓi don keɓe kai tsaye
fayilolin da in ba haka ba da sun dace da su
Kuna iya lissafin regexes da yawa, ware ta sarari
Amfani na yau da kullun zai zama: --excludes node_modules dist \.git build tmp
Matsalolin da za a fassara na iya ƙunsar samfuri {{ handlebars }}
, ko dai tare da takalmin gyaran kafa biyu ko uku.
Wataƙila KADA kuna son a fassara abubuwan da ke cikin waɗannan samfuran
Wuce -H
/ --handlebars
, kuma duk wani abu da ke cikin {{ ... }}
ba za a fassara shi ba
Markdown ba rubutu bane ko html, don haka Google Translate yana da wasu matsaloli tare da shi
-M
/ --markdown
ba da damar sarrafa musammam don fayiloli masu alama
Tare da fayilolin alama, idan ba ku yi amfani da tutar -M
ba, ƙila za ku sami waɗannan matsalolin:
- Abubuwan da aka karye. A cikin fassarar, yanayin sararin samaniya yana bayyana bayan bayanin hanyar haɗin gwiwa ya ƙare (tare da
]
) amma kafin a fara hanyar haɗin yanar gizon sa (tare da(
) Wannan yana sa alamar ta yi kuskure, da kuma hanyar haɗin yanar gizon. ya karye lokacin kallon takardar. - An fassara tubalan lamba. Google Translation bai san abin da alamar ke ɗaukar lamba da abin da baya sani ba
- Ba daidai ba tazara don tubalan lambobi. Tazara yana da wuyar adanawa a cikin fassarar
- Abubuwan da ke cikin
backticks
za a fassara su, lokacin da kusan koyaushe kuna son su zama dabi'u na zahiri
Lokacin da aka kunna tutar -M
/ --markdown
:
- Alamar
](
za'a tattara ta zuwa](
don haka gyara hanyoyin haɗin da aka karye - Za a sanya murfi na "babu fassarar" a kusa da ɓangarorin lambobi, adana ingantacciyar shigar da kuma tabbatar da cewa ba a fassara su ba.
- Za a sanya murfi na "babu fassara" a kusa da rubutu a cikin
backticks
don tabbatar da cewa ba a fassara su ba
Yawanci ana sarrafa komai azaman rubutu bayyananne
Idan abun cikin ku HTML ne, zai lalace sai dai idan kun wuce -p html
/ --process-as html
Ga masu sha'awar: lokacin sarrafa fayiloli a cikin kundin adireshi, zaku iya wuce -F
/ --filter
don tace fitarwa kafin a rubuta shi zuwa tsarin fayil
Dole ne ƙimar wannan zaɓi ta zama hanya zuwa fayil ɗin JS wanda ke fitar da aiki mai suna filter
Aikin filter
dole ne ya zama async
saboda await
za a kira shi
Kafin a rubuta fayiloli zuwa faifai, za a wuce duk abin da ke cikin fayil ɗin zuwa aikin filter
azaman kirtani
Ƙimar dawowa daga aikin filter
shine ainihin abin da za a rubuta zuwa wurin ajiya
Don haka, kuna da cikakken iko akan abin da a ƙarshe za a rubuta
Za a nemo rubutun filter
a wurare masu zuwa (tare da .js
za a saka a cikin tacewa.
suna, sai dai idan ya riga ya ƙare a .js
)
- Littafin jagora na yanzu
- Littafin adireshi mai suna
.hokey-filters
a cikin kundin adireshi na yanzu - Littafin adireshi mai suna
${HOME}/.hokey-filters
, inda${HOME}
shine kundin adireshin gida na mai amfani na yanzu - Ginin da aka gina (directory directory)(https://github.com/cobbzilla/hokeylization/tree/master/util/filter)
filter
na iya zama kalmomi da yawa. A wannan yanayin, kalmar farko ita ce sunan tace, kuma
sauran kalmomin za a wuce su azaman muhawara zuwa aikin filter
Yi amfani -h
/ --help
don nuna taimako
Tare da -j
/ --json
, zaku iya gudanar da umarni na hokey
masu daidaitawa da yawa.
Ta al'ada wannan fayil ana kiransa hokey.json
, amma zaka iya sanya masa suna duk abin da kake so
Idan kun wuce kundin adireshi azaman zaɓi na -j
, hokey
zai nemi hokey.json
a cikin wannan kundin adireshin
Fayil ɗin JSON yakamata ya ƙunshi abu ɗaya. A cikin wannan abun, sunayen kadarorinsa iri daya ne da
zaɓuɓɓukan layin umarni, da ƙarin dukiya guda ɗaya mai suna hokey
Kayan hokey
jerin umarni ne don gudana. Kaddarorin da aka bayyana a cikin waɗannan umarni zasu
soke duk wani kwafin bayanin da ke cikin abin waje.
A cikin kowane abu a cikin tsararrun hokey
, yakamata ku saka name
, da shigar da fayilolin fitarwa.
Ga misalin 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"
}
]
}
Wuce jerin hanyoyin fayil azaman infiles
maimakon hanya infile
, kamar a cikin wannan misali:
{
... [
{
"name": "my docs",
"infiles": ["README.md", "INSTALL.md", "TUTORIAL.md"],
"outfile": "docs/LANG/",
"markdown": true
]
}
Lokacin fassara zuwa harsuna da yawa, hokey
iya ƙirƙirar fayil ɗin fihirisa wanda ya jera duk fassarorin da aka yi
kuma yana ba da hanyoyin haɗi zuwa gare su
Lokacin samar da fihirisa, za ku iya samun tushen shigarwa guda ɗaya kawai
Wuce zaɓi na -I
/ --index
, ƙimar ita ce inda za a samar da fayil ɗin fihirisa, wanda zai iya zama fayil
ko directory. Idan kundin adireshi ne, za a yi amfani da tsohon sunan fayil, dangane da samfuri (duba ƙasa)
Yi amfani da -A
/ --index-template
don tantance yadda aka tsara fitarwar fihirisa. Kuna iya saka 'html',
'markdown', 'rubutu', ko hanyar fayil zuwa naka HandlebarsJS samfuri
Idan kun saka samfurin ku, dole ne ku kuma saka fayil (ba directory) na -I
/ --index
zaɓi