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 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题