当前位置: 首页 > 工具软件 > dasBlog > 使用案例 >

DasBlog可用性警报:模板更改以启用土耳其语用户

谢承颜
2023-12-01

DasBlog uses a poor man's macro language in our templates to make it easy to change the skin of a whole blog. The macros allow folks to call methods from our templates, with or without parameters.

DasBlog在我们的模板中使用穷人的宏语言来简化整个博客的外观。 宏允许人们从带有或不带有参数的模板中调用方法。

We use some reflection code like this:

我们使用一些反射代码,如下所示:

MemberInfo[] members = subexObject.GetType().FindMembers(
    MemberTypes.Field|MemberTypes.Method|MemberTypes.Property,
    BindingFlags.IgnoreCase|BindingFlags.Instance|BindingFlags.Public,
    new MemberFilter(this.IsMemberEligibleForMacroCall), subex.Trim());

Where "subex" contains a string like "items" that was extracted from one of our template files that included a macro string like <%items%> indicating to dasBlog to insert a list of blog items here.

其中,“ subex”包含一个类似“ items”的字符串,该字符串是从我们的模板文件之一中提取的,其中包括一个宏字符串,例如<%items%>,指示dasBlog在此处插入博客项目列表。

However, when someone using a Turkish browser comes to a site running dasBlog they see NOTHING. Zip. Why?

但是,当使用土耳其语浏览器的人进入运行dasBlog的站点时,他们会看到“无”。 压缩。 为什么?

In Turkish, there are four letter "I's. In English our i becomes I when capitalized. However, in Turkish, i becomes İ and ı becomes I. Notice the dots. 

在土耳其语中,有四个字母“ I's。在英语中,大写的i变成了我。但是,在土耳其语中,i变成了İ,ı变成了I。注意点。

Also, notice that we use BindingFlags.IgnoreCase in our call to FindMembers(). I suspect that the "items" is becoming "Items" internally (perhaps an in appropriate call to ToUpper()?) but I can't find an implementation with Reflector that even looks at BindingFlags.IgnoreCase. Regardless, we fail to call the method and get a System.MissingMemberException or System.MissingMethodException.

另外,请注意,在对FindMembers()的调用中,我们使用BindingFlags.IgnoreCase。 我怀疑“项目”在内部正在变成“项目”(也许是对ToUpper()的适当调用?),但是我找不到使用Reflector甚至看不到BindingFlags.IgnoreCase的实现。 无论如何,我们都无法调用该方法并获得System.MissingMemberException或System.MissingMethodException。

ACTION REQUIRED: The solution is, for now, for all you folks running dasBlog, to go into your *.template files and make these quick and easy changes (there isn't yet an easy code change, and it's not just a ToUpper() situation):

需要采取的措施:目前,对于所有运行dasBlog的人来说,解决方案是进入* .template文件并进行快速,轻松的更改(尚不容易进行代码更改,而不仅仅是ToUpper( )情况):

  • Change <%items%> to <%Items%>

    将<%items%>更改为<%Items%>
  • Change <%itemTitle%> to <%ItemTitle%>

    将<%itemTitle%>更改为<%ItemTitle%>
  • Change <%itemText%> to <%ItemText%>

    将<%itemText%>更改为<%ItemText%>

I'll make changes to all the default dasBlog templates while I look for a more correct solution in code and/or determine if this is a limitation in FindMembers(). 

我将在所有默认的dasBlog模板中进行更改,同时在代码中寻找更正确的解决方案和/或确定这是否是FindMembers()中的限制。

翻译自: https://www.hanselman.com/blog/dasblog-usability-alert-template-changes-to-enable-turkish-users

 类似资料: