dsa45132 2019-02-26 14:55
浏览 52
已采纳

多语言@ Server API + Android应用程序

I have Android Application which are supprting multilanguage (Russian & Latvian), no questions to this.

Problem is, that my backend is on CI and I have some definied Strings (mostly technical), example (Russian):

define('ALL_CAT',"Все категории");
define('NO_DATA',"Ничего нет.");

And if Application is in Latvian, then I will in any case see this Russian strings.

Is it possible somehow translate Backend CI Api Strings?

(Or, move all API string to client and show them from client - if this possible, idk)

PS: Also I have no saved Language on client side. It means if User open Application and select Latvian, use Application on Latvian, but when application closed/reopened user must select Latvian again ;-)

Thank you in advance,

  • 写回答

1条回答 默认 最新

  • 普通网友 2019-02-26 14:59
    关注

    Yes. The solution is to send a placeholder instead of russian.

    define('ALL_CAT',"placeholder::ALL_CAT");
    define('NO_DATA',"placeholder::NO_DATA");
    

    Then, whenever your client encounters a placeholder string:

    String recieved = getStringFromServer();
    if(recieved.indexOf("placeholder") == 0){
        recieved == //rusian or latvian.
    }
    

    You translate that placeholder string with a lookup table. You can define that lookup table in a file in your app, or in a database on a server somewhere.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程