使用 CSS 文件进行站点本地化
我正在使用 ASP.net MVC 2.0 创建一个网站,该网站使用两种不同的语言(英语和波斯语)。我想要这些语言有两种不同的布局,英语有从左到右的布局,波斯语有从右到左的布局。
我想到的是,如果我可以有两个不同的 css 文件,就像当你使用字符串或图像本地化来完成网站的工作一样,问题是我需要知道如何做到这一点!
关于如何执行此操作的任何其他建议都会有所帮助。
I'm creating a website with ASP.net MVC 2.0 which uses two different languages (English and Persian). I want to have two different layouts for these languages, English has a left to right and Persian has a right to left layout.
What came to my mind was, if I could have two different css files, like when you do it with string or image localization will do the work for the site, the problem is I need to know how to do this!
Any other suggestions on how to perform this would be helpful.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用此代码在客户端获取区域设置。定义区域设置后,您可以在标头中动态包含样式表。
This is the code you can use to get the Locale at the client side. Once you have the locale defined, you can dynamically include a stylesheet in the header.
不确定这是否是您想要的,但几年前我用 VBScript 做到了这一点。不理想,但它对我有用:
弄清楚语言:
设置样式表...
如果这有帮助,我可以发布更多片段。
Not sure if this is what you ar elooking for, but I did this a few years back in VBScript. Not ideal, but it works for me:
Figure out the language:
Set the style sheet...
I can post more snippets if this is helpful.
您可以阅读:
在您的页面中:
alt
);每个具有方向性的图像都应该反转(例如:箭头),class="left"
这样的类命名。顶部、底部、之前或之后都可以,但左/右不行(编辑:CSS3 中现在使用start
和end
来避免 ltr 和 rtl 的这种确切问题。比已经用于带有冒号的伪符号的*-before
和*-after
更好)。text-align
、background-position
、float
、clear
和显然左
和右
与位置:绝对/相对;
。新的 CSS3 指令也要回顾(动画等)。如上面的链接所述,使用了 HTML 属性
dir="rtl"
。您还需要一个类(在body
上或某些包含div
的类上,以充当满足您设计需求的巨型开关。就像属性选择器一样,因为 IE8 包含了。
You can read about:
In your pages:
alt
); every image with directionality should be reversed (ex: an arrow)class="left"
if you don't want future headaches. Top, bottom, before or after are OK but not left/right (edit:start
andend
are now used in CSS3 to avoid this exact problem of ltr and rtl. May be better than*-before
and*-after
already used for pseudos with colons).text-align
,background-position
,float
,clear
and obviouslyleft
andright
withposition: absolute/relative;
. New CSS3 instructions are to review too (Animations, etc).As noted in the links above, the HTML attribute
dir="rtl"
is used. You'll also need a class (onbody
or some containingdiv
to act like a giant switch for your design needs. LikeThe attribute selector does the same, since IE8 included.