客户可以对线上文案进行热更新修复,并避免重新发版成本,直接将补丁下发至指定版本;
客户端补丁发布流程请参考客户端补丁发布。
在根目录的build.gradle中加入火山引擎Maven服务地址
allprojects { repositories { ... maven { url "https://artifact.bytedance.com/repository/Volcengine/" } } }
api 'com.volcengine:volci18n-core:$latestVersion'
当前最新版本:
| 适用场景 | 版本 |
|---|---|
非AndroidX | 1.0.6 |
| AndroidX且appcompat版本 >= 1.2.0 | 1.0.7-androidx-1.2.x |
在Application的onCreate方法中执行初始化操作
Kotlin:
VolcI18nSdk.init(CommonConfig( context, // ApplicationContext "host" //平台提供的host:client-api.multilingual-volc.com "nameSpace", // 平台上配置的NameSpace "accessKey", // 平台上配置的AccessKey "lang", // 语言(示例:en-US) locale, // locale "1.0.0", // appVersion "352157255", // deviceId true // enable ))
Java
CommonConfig commonConfig = new CommonConfig( context, // ApplicationContext "host", //平台提供的host:client-api.multilingual-volc.com "nameSpace", // 国际化翻译平台上配置的NameSpace "accessKey", // 国际化翻译平台上配置的AccessKey "lang", // 语言(示例:en-US) locale, // locale "1.0.0", // appVersion "352157255", // deviceId true // 开关,是否开启热更新能力 ); VolcI18nSdk.init(commonConfig);
| 参数名称 | 类型 | 是否必选 | 参数说明 |
|---|---|---|---|
| context | Context | 是 | 应用的Context |
| host | String | 是 | 平台提供的host:client-api.multilingual-volc.com |
| nameSpace | String | 是 | 平台上配置的 空间标识 |
| accessKey | String | 是 | 平台上配置的AccessKey |
| lang | String | 是 | 当前系统的语言,例如(en-US),需要和国际化翻译平台上配置的语言名称保持完全一致,大小写敏感。 |
| locale | Locale | 是 | 当前系统的Locale,需要和语言保持一致 |
| appVersion | String | 是 | APP版本号,补丁发布时候会按此版本号来分发 |
| deviceId | String | 是 | 设备的deviceId |
| enable | Boolean | 是 | 是否开启热更新能力 |
class App : Application() { ...... override fun attachBaseContext(base: Context?) { super.attachBaseContext(VolcI18nSdk.wrapContext(base)) } ...... }
class BaseActivity : Activity() { ...... override fun attachBaseContext(base: Context?) { super.attachBaseContext(VolcI18nSdk.wrapContext(base)) } ...... }
如果使用AndroidX,且AppCompat版本>=1.2.0
需要在基类的Activity中再增加如下代码
override fun getDelegate(): AppCompatDelegate { return VolcI18nSdk.getAppCompatDelegate(super.getDelegate()) }
如果想要更新自定义View中的文案,需要用如下的方式:
val testText =VolcI18nSdk.getTypeArrayString(typedArray, R.styleable.CustomView_test_text)
替换掉原生的
val testText = typedArray.getString(R.styleable.CustomView_test_text)
接入遇到问题,欢迎发起工单进行咨询。