Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Introduction of Aizome - 多言語対応とスタイル適用を両立する書式付き文...

Introduction of Aizome - 多言語対応とスタイル適用を両立する書式付き文字列ライブラリ

2025/05/27(Thr) potatotips #91 iOS/Android開発Tips共有会
https://potatotips.connpass.com/event/353344/

## 関連URL

Aizome
https://github.com/iseebi/aizome-compose
https://github.com/iseebi/aizome-swiftui

文字列で柔軟に書式を指定できるライブラリ Aizome を作った
https://iseebi.hatenablog.com/entry/2025/04/20/194527
https://zenn.dev/iseebi/articles/aizome_introduction

複数チームでのアプリ開発におけるローカライズ文言の管理手法
https://techblog.goinc.jp/entry/2024/12/08/090000

Avatar for Nobuhiro Ito

Nobuhiro Ito

May 27, 2025
Tweet

More Decks by Nobuhiro Ito

Other Decks in Programming

Transcript

  1. ίʔυྫೖΕΔ @Composable fun SampleView() { Text( buildAnnotatedString { withStyle(SpanStyle(color =

    Color.Blue, fontWeight = FontWeight.Bold)) { append("会員登録") } append("を完了してください") } ) }
  2. <resources> <string name="register_before">Please complete</string> <string name="register_accent">register</string> <string name="register_after" /> </resources>

    <resources> <string name="register_before" /> <string name="register_accent">会員登録</string> <string name="register_after">を完了してください</string> </resources> @Composable fun SampleView() { Text( buildAnnotatedString { append(stringResource(R.string.register_before)) withStyle(SpanStyle(color = Color.Blue, fontWeight = FontWeight.Bold)) { append(stringResource(R.string.register_accent)) } append(stringResource(R.string.register_after)) } ) }
  3. ελΠϧఆ͕ٛ؆୯Ͱॊೈ 4QBO4UZMF͕ͦͷ··࢖͑ΔɺͦͷؾʹͳΕ͹ಈతఆٛ΋Մೳ Aizome.instance.setDefaultStyles( mapOf( "bold" to SpanStyleStringStyle(SpanStyle(fontWeight = FontWeight.Bold)), "italic"

    to SpanStyleStringStyle(SpanStyle(fontStyle = FontStyle.Italic)), "red" to SpanStyleStringStyle(SpanStyle(color = Color.Red)), "blue" to SpanStyleStringStyle(SpanStyle(color = Color.Blue)), "green" to SpanStyleStringStyle(SpanStyle(color = Color.Green)), ), )
  4. IPTIJͱͷ࿈ܞ w จݴͷ؅ཧʹIPTIJΛ࢖͏ͱͭͷఆ͔ٛΒɺ J04"OESPJEͦΕͧΕͷܗࣜͰॻ͖ग़ͤΔ w IPTIJͱ"J[PNFΛ૊Έ߹Θͤͯ࢖͏ͱ ελΠϧ෇͖ϩʔΧϥΠζ͕ ճͷఆٛͱฏқͳ࣮૷Ͱ׬ྃ  JTFFCJIPTIJ

    ෳ਺νʔϜͰͷΞϓϦ։ൃʹ͓͚ΔϩʔΧϥΠζจݴͷ؅ཧख๏ IUUQTUFDICMPHHPJODKQFOUSZ phrases: please_register: en: Please complete <accent>register</accent> ja: <accent>会員登録</accent>を完了してください "please_register"="<accent>会員登録</accent>を完了してください"; IPTIJจݴఆٛ :".- <string key="please_register"> &lt;accent&gt;会員登録&lt;/accent&gt;を完了してください </string> J04TUSJOHT "OESPJETUSJOHTYNM