duandu8707 2017-03-22 10:40
浏览 163
已采纳

Laravel 5 - 多语言网站(LTR和RTL)

Hi to all developers...

I'm new to Laravel. I want to build a complex web application and it's important to support at least 2 language. Unfortunately, One of these language is LTR and other is RTL!
My questions are:

  1. Some parts of website have static content, like headers, navigation items, sidebar content or... . As I understand, I must create files in lang directory and based on selected language, load proper data. Is it right? In this way, Is it possible to load these static data from lang directory files cause slower app and bad performance? (compare with static views, blade files that have content and don't need to load small piece of data from lang directory).
  2. Considering first question, is it better to have one set of views for one language and another set of views for second language? (each set of views have their static data and don't require use lang files to full parts of header, sidebar and...)
  3. As I said, I must have a LTR and a RTL layout in order to have best UI. So I must have separate stylesheets and loads based on choosen language, is it right?

I have some questions for multi language database design, but I start a new discussion later. Thanks for your attention and I hope that you guide me and say your opinions...

  • 写回答

1条回答 默认 最新

  • doufei8691 2017-03-22 11:11
    关注

    Some parts of website have static content, like headers, navigation items, sidebar content or... . As I understand, I must create files in lang directory and based on selected language, load proper data. Is it right? In this way, Is it possible to load these static data from lang directory files cause slower app and bad performance? (compare with static views, blade files that have content and don't need to load small piece of data from lang directory)

    • Yes, by all means make sure you abstract your language from your views. This is a good practice that you will definitely want to do to save yourself multiple identical views per language (nightmare!).
    • When you program anything there is a performance overhead. When you use functionality such as this, you're making your life a lot easier. The performance hit is tiny. Don't use this as a reason to not do this.

    Considering first question, is it better to have one set of views for one language and another set of views for second language? (each set of views have their static data and don't require use lang files to full parts of header, sidebar and...)

    • No, this is a nightmare scenario for most developers. Maintaining multiple brittle views due to language eats up time when separation of these concerns at the beginning removes any need for this to happen.

    As I said, I must have a LTR and a RTL layout in order to have best UI. So I must have separate stylesheets and loads based on choosen language, is it right?

    • LTR and RTL is a problem wholly solvable using some simple CSS alone, no need to have separate style sheets. Instead, using a single class on the body you can apply the correct styling. <body class="{{ $rtl ? 'rtl' : 'ltr'}}">. Now you can use CSS' direction property to define the direction text reads.

    As you are using Laravel, leverage the framework as much as you can. There is no need for you to re-invent the wheel with this.

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

报告相同问题?

悬赏问题

  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)