éåžžã®gettextã«å¯ŸããFluentã®å©ç¹ã«ã€ããŠã®è°è«ãç¶ããŠã翻蚳ã«ãããFluent ã®äœæè
ã®å
¬åŒãªç«å Žãå
¬ââéããŸãã
Gettextã¯ãGNUãããžã§ã¯ããšãã®é¢é£ã¢ãŒããã¯ãã£ãœãªã¥ãŒã·ã§ã³ã«æ·±ãæ ¹ãããããŒã«ãªãŒãŒã·ã§ã³ã·ã¹ãã ã§ãã
Fluent Projectã¯ãgettextããèªã¿ããã圢åŒã®ããŒã«ã©ã€ãºãã¡ã€ã«ã䜿çšããŠè£œåãªãªãŒã¹ãµã€ã¯ã«å
šäœã管çããããã®ãã©ã€ãã©ãªããã³ããŒã«ã®å®å
šãªäœã¬ãã«ã®ãã©ãããã©ãŒã ã«äŸåããªããšã³ã·ã¹ãã ã®è¯ãäŸãšèããŠããŸãã åæã«ãFluentãã©ãã€ã ã¯ãéèŠãªããŒã«ã©ã€ãºã®åŽé¢ã§ä»ã®ã¢ãŒããã¯ãã£ãœãªã¥ãŒã·ã§ã³ã«ã€ãªããããã®çµæãå®å
šã«ç°ãªãAPIãšã©ã€ããµã€ã¯ã«ã«ã€ãªãããŸãã
èšãæããã°ãgettextã¯çŽ æŽããããããžã§ã¯ãã§ãããããŒã«ã©ã€ãºãžã®ã¢ãããŒãã«é¢ããèŠè§£ãå
±æããŠããŸããã
gettextãšFluentã®äž»ãªéãã¯æ¬¡ã®ãšããã§ãã
æé
gettextãšFluentã®æãéèŠãªéãã¯ãã¡ãã»ãŒãžèå¥åã§ãã Gettextã¯ããœãŒã¹æååïŒéåžžã¯è±èªïŒãèå¥åãšããŠäœ¿çšããããšã«ããŸããã ãã®éžæã¯ç°¡åã«æããŸãããããã«å€ãã®å¶éã課ãããŸãã
ãŸãããã®ã¢ãããŒãã§ã¯ãå
ã®è¡ãå€æŽãããšãããã«é¢é£ä»ããããŠãããã¹ãŠã®ç¿»èš³ãç¡å¹ã«ãªããŸãã ããã¯ããã¹ãŠã®ç¿»èš³ãæŽæ°ããå¿
èŠããããããéçºè
ã®è² è·ã倧å¹
ã«å¢å ãããå
ã®ã¡ãã»ãŒãžãå€æŽããªãããã«ããŸãã
第äºã«ããœãŒã¹èšèªã§åãããã¹ããæã€è€æ°ã®ã¡ãã»ãŒãžã®å°å
¥ãè€éã«ãªããç°ãªãæ¹æ³ã§ç¿»èš³ããå¿
èŠããããŸãã ããšãã°ããéãããã¿ã³ãšãéããããŒã¯ã®ããã¹ãã¯ãæåã®ããã¹ããã³ãã³ãã§ã2çªç®ã説æã§ãããããããŸããŸãªæ¹æ³ã§ç¿»èš³ã§ããŸãã Gettextã«ã¯ãåããœãŒã¹ã»ã°ã¡ã³ããæã€è¡ãåºå¥ããããã®ãªãã·ã§ã³ã®
msgctxtã³ã³ããã¹ãè¡ããããŸãã ãã®ã¢ãããŒãã¯ãéçºè
ã«ãã®ãããªç¶æ³ãèªèãã責任ãè² ããŸããããã¯ãå©çã®åé¢ã®ååãšççŸããŸãã
Fluentã¯ããŸãã«ãã®çç±ã§ããã¹ããåå©çšããããšãæšå¥šããŠããŸããã ãœãŒã¹ããã¹ããä»ã®ç¿»èš³ããåé¢ããããšããè€åã¡ãã»ãŒãžïŒ1ã€ã®ç¿»èš³åäœã®è€æ°ã®è¡ãå«ã¿ã1ã€ã®ãŠãŒã¶ãŒã€ã³ã¿ãŒãã§ã€ã¹ãŠã£ãžã§ããã«ã¢ã¿ãããããŠããïŒãå
¥åããæ©èœããã³ã¡ãã»ãŒãžãžã®èå¥åããŒã¹ã®ãªã³ã¯ã«ãšã£ãŠéèŠã§ãã
Fluentã¯ãéçºè
ãšããŒã«ã©ã€ã¶ãŒã®éã«ãåæãã確ç«ããŸãã éçºè
ã¯äžæã®èå¥åãšäžé£ã®å€æ°ïŒæªèªã¡ãã»ãŒãžã®æ°ããŠãŒã¶ãŒåãªã©ïŒãå
¥åããFluentæ§æã䜿çšããŠããŒã«ã©ã€ã¶ãŒããã®èå¥åã®ã¡ãã»ãŒãžããã¹ãã®äœææ¹æ³ã決å®ããŸãã
éçºè
ã¯ããã®ãããªã¡ãã»ãŒãžã®ç¿»èš³ã®è©³çŽ°ãªå®è£
ã«ã€ããŠå¿é
ããã¹ãã§ã¯ãããŸããã éçºè
ã«å¿
èŠãªã®ã¯ãUIã®ç¹å®ã®å Žæã«é©ãã1è¡ã®ããã¹ããååŸããŠãç¹å®ã®èå¥åã§è¡ãèŠæ±ããããšã§ãã
ã¡ãã»ãŒãžãªãã·ã§ã³
Gettextã¯ãç¹ã«è€æ°åœ¢ã®åœéåã®ããã«ãå°ããªé¢æ°ã»ããããµããŒãããŠããŸãã ãã ãããã®ãããªè€æ°ã®æ§æã¯ãæšæºã®gettextæ§æã«å ããŠç¹æ®ãªã±ãŒã¹ã§ãããå¯å€æ§ãå¿
èŠãšããä»ã®ã±ãŒã¹ã«åãããŠæ¡åŒµããããšã¯å°é£ã§ãã
Fluentã¯ãã»ã¬ã¯ã¿ãŒã§äœ¿çšã§ããæååããªãšãŒã·ã§ã³ã®åºæ¬æŠå¿µããµããŒãããŠããŸãã éåžžãè€æ°èŠåã¯ãã®ãããªã»ã¬ã¯ã¿ãŒã«ãªããŸãããèšèªã®ææ³çãªç¹åŸŽã«ãã£ãŠã¯ãæ§å¥ãåè§ããŸãã¯ç°å¢ïŒäŸïŒæå»ããªãã¬ãŒãã£ã³ã°ã·ã¹ãã ãªã©ïŒãååšããå ŽåããããŸãã Fluentæ§æã䜿çšãããšãããŒã«ã©ã€ã¶ãŒã¯ããããã¹ãŠã®æ©èœãæ€èšããç¶æ³ã«å®å
šã«äžèŽããããã¹ããäœæã§ããŸãã
å€éšåŒæ°
Gettextã¯å€éšåŒæ°ããµããŒãããŠããŸããã èšãæãããšããã©ã¡ãŒã¿ãŒã®åœ¢åŒïŒæ°å€ãæ¥ä»ïŒãèšå®ããããšã¯ã§ããŸããã gettextã®ãã©ã¡ãŒã¿ãŒããã©ãŒãããããã«ã¯ã
printfã«æž¡ãæååãè¿ãããçµæã®æååã§
String.prototype.replaceãå®è¡ããããšããå§ãããŸãã
Fluentã§ã¯ãå€éšåŒæ°ã®ãµããŒããæ§æã®äžå¿ã«ãããŸãã å€éšåŒæ°ã¯è£éãããã ãã§ãªããã»ã¬ã¯ã¿ãŒã®ãã©ã¡ãŒã¿ãŒãšããŠã䜿çšãããçµã¿èŸŒã¿é¢æ°ã«è»¢éããããšãã§ããŸãã ããã«ãããããŒã«ã©ã€ã¶ãŒã¯ç¹å®ã®ã±ãŒã¹ã«å¯ŸããŠããæ£ç¢ºãªããã¹ããäœæã§ããŸãã ããã«ãFluentã¯ãªããžã§ã¯ãã®åšå²ã«
FSI / PDIããŒã«ãŒãé
眮ããŠãåæ¹åããã¹ãã®æåæ§åé¢ãä¿è·ãããªãŒãæååã®æäœãçŠæ¢ããŠãéçºè
ã®è² æ
ã軜æžããŸãã
責任ã®åé¢
ããã«ãgettextãè€æ°ã®ã«ãŒã«ãåŠçããæ¹æ³ã§ã¯ãã·ã¹ãã èšèšè
ãã¡ãã»ãŒãžãå€å€éã¡ãã»ãŒãžã«ãããåäžè¡ã«ããããéžæããå¿
èŠããããŸãã Fluentã®èŠ³ç¹ãããããšãéçºè
ã¯ãã®ãããªåé¡ã«å¯ŸåŠãã¹ãã§ã¯ãããŸããã å€ãã®å Žåãè±èªã§1ã€ã®ãªãã·ã§ã³ã§ååãªå Žåãä»ã®èšèªã§ã¯è€æ°åœ¢ã®ããªã¢ã³ããè¿œå ããå¿
èŠããããŸãã
Fluentã¯ãå€ãã®ãã±ãŒã«ã§ãœãããŠã§ã¢ãéçºããå Žåãéçºè
ãåæ§ã®èšèªç¥èãæã£ãŠããŠã¯ãªãããåèšèªã«ã¯ããŒã«ã©ã€ãºäžã«ç¹å®ã®ã¢ã¯ã·ã§ã³ã®èªç±ãããã¹ãã ãšæ³å®ããŠããŸãã
ãã®çµæãFluentã¯ãããèšèªã®èŠä»¶ãå¥ã®èšèªã«ãæŒãããããšãªãå翻蚳ãåå¥ã«ä¿åããããŒã«ã©ã€ã¶ãŒãç¹å®ã®è¡ã«å¿
èŠãšããæ©èœãå¿é
ããå¿
èŠã®ãªãéçºè
ã®ããã«ãã¹ãŠã®ç¿»èš³ããäžéæãã«ä¿ã¡ãŸãã
æ¯èŸŒã®ãã£ã³ã»ã«
éçºãµã€ã¯ã«ã§ã¯ã翻蚳ããªãªãžãã«ã«å¯ŸããŠããã£ã³ã»ã«ãïŒç¡å¹ã«ãªãïŒç¶æ
ã3ã€ãããŸãã
- ããããªå€æŽïŒç¿»èš³ã«åœ±é¿ããŸããïŒæ£ããå¥èªç¹ãã¿ã€ããã¹ïŒã
- äžçšåºŠã®å€æŽïŒã¡ãã»ãŒãžã®ãã¶ã€ã³ã«åœ±é¿ããŸãããé¢é£ãã翻蚳ã®æ£ç¢ºæ§ã¯ãã£ã³ã»ã«ãããŸããïŒããšãã°ã ãã¹ãŠã®ããã¯ããŒã¯ã 衚瀺 -> ããã¯ããŒã¯ãããŒãžã£ãŒã衚瀺 ïŒã
- éèŠãªå€æŽïŒæã®æ°ããæå³ïŒ ã¯ãªãã¯ããŠä¿å -> ã¯ãªãã¯ããŠéããŸã ïŒã
ã¢ãŒããã¯ãã£äžã®çç±ã«ãããgettextã¯3ã€ã®ã¬ãã«ãã¹ãŠã
fuzzyãšåŒã°ãã1ã€ã®ç¶æ
ã«çµåããŸãã ãœãŒã¹è¡ã®å€æŽïŒå°ãªããšãå®å
šãå°ãªããšãéèŠã§ãªãïŒã¯ã翻蚳ã®åãæ¶ãã«ã€ãªãããŸãã
Fluentã§ã¯ãäžæã®èå¥åã䜿çšããããšã§ããããã®ã¬ãã«ã®ãã¡2ã€ã3ã€ç®ã®ã¬ãã«ãšã¯å¥ã«ä¿ã€ããšãã§ããŸããè¡ã®ãœãŒã¹ããã¹ãã«
å°ããªå€æŽãå ããèå¥åãä¿åãããšã翻蚳ã¯æå¹ãªãŸãŸã§ãã äžæ¹ãéçºè
ãèå¥åãå€æŽãããšããã¹ãŠã®ç¿»èš³ããã£ã³ã»ã«ãããæŽæ°ãå¿
èŠã«ãªããŸãã
ãã®ãããªã¢ãŒããã¯ãã£ãœãªã¥ãŒã·ã§ã³ã¯ãã»ãšãã©ã®ãªãªãŒã¹ãµã€ã¯ã«ã§ããæçã§ãããšèããŠããŸããã
äžéã¬ãã«ã®å€æŽã®å Žåãéçºè
ã¯èå¥åãä¿åãããå€æŽããããéžæããå¿
èŠããããŸãïŒã€ãŸãã
ãã€ã㌠ãªå€æŽãš
éèŠãªå€æŽã®ã©ã¡ããïŒã
ãŸããéçºè
ãã¡ãã»ãŒãžããã®å
容ãå®å
šã«ç¡å¹ã«ããããšãªã
æŽæ°æžã¿ãšããŠããŒã¯ã§ããããã«ãã¡ãã»ãŒãžã®
ããŒãžã§ã³ç®¡çã®ã¢ã€ãã¢ãæ€èšããŠããŸãã ãã®ç¶æ
ã§ã¯ãå€ãããŒãžã§ã³ã®ç¿»èš³ãæªç¿»èš³ã®æååãããåªããŠãããšãã芳ç¹ã«åºã¥ããŠã翻蚳ãæå¹ã«ä¿ã€ããšãã§ããåæã«ããŒã«ã¯ç¿»èš³ãæŽæ°ããå¿
èŠæ§ã«ã€ããŠããŒã«ã©ã€ã¶ãŒã«éç¥ã§ããŸãã
ããŒã¿åœ¢åŒ
Gettextã¯ã* .poã* .potãããã³* .moã®3ã€ã®ãã¡ã€ã«åœ¢åŒã䜿çšããŸãã ããã¯ãçç£ãµã€ã¯ã«ã§ã®gettextã®å®è£
ã«åœ±é¿ãäžããã¡ãã»ãŒãžã®æœåºãã³ã³ãã€ã«ãªã©ã®æé ãè¿œå ããŸãã
Fluentã¯ãåäžã®* .ftlãã¡ã€ã«åœ¢åŒã䜿çšããŸããããã«ãããå®è£
ãç°¡çŽ åãããããŒã¿ã®äžäžèŽãæãå¯èœæ§ãããè¿œå ã®æé ãäžèŠã«ãªããŸãã
UnicodeãµããŒã
Gettextã¯UTF-8ã§ãšã³ã³ãŒãã§ããŸãã äžè¬çã«ãããã§UnicodeãµããŒããçµäºããŸãã è€æ°åœ¢ã«ç¬èªã®ããŒã¿ã»ããã䜿çšããæ¥ä»ãšæ°å€ã®æžåŒèšå®æ¹æ³ããããããåæ¹åããã¹ãã®æäœã«åœ¹ç«ã¡ãŸããã
Fluentã¯ãæšæºåãããã©ã€ãã©ãªãšCLDRãICUãããã³ECMA402ã¢ã«ãŽãªãºã ãåºç¯å²ã«äœ¿çšããããŒã«ãªãŒãŒã·ã§ã³ãšåœéåãããŸãçµã¿åãããŠããŸãã
ãããã«
Fluent APIãšæ§æã¯gettextããã倧å¹
ã«æ¹åãããŠãããšæããããããåœéçãªãœãããŠã§ã¢ã«äœ¿çšããããšããå§ãããŸãã
Fluentã®è©³çŽ°