我有一个WinForms应用程序,我想将其翻译成多种语言.但是,我没有任何本地化WinForms应用程序的经验,我发现有关此主题的非常矛盾的信息.
基本上,我想要的是:
我见过的大多数解决方案要么每个表单都有一个.resx文件和/或外部附属程序集.
我必须自己动手吗?或者框架中有什么东西吗?
.net Framework 3.5 SP1如果重要的话.
编辑:在大多数情况下,Visual Studio已经提供了我想要的支持,但有两个问题.当我将Form.Localizable设置为true时,我有这个很好的设计器支持,但是这会为每个表单生成一个resx.在InitializeComponent中手动覆盖它的想法失败了,因为它是经常被覆盖的设计者编写的代码.从理论上讲,我只想a)覆盖ComponentResourceManager的创建,将其指向我的全局resx,b)将对ApplyResources的调用更改为将CultureInfo作为第三个参数的重载.
好像我必须在我的构造函数中添加一个函数调用,该函数调用在InitializeComponent()之后调用并覆盖它的行为.这似乎非常低效,但Visual Studio在警告触摸InitializeComponent时是正确的.目前,我确实正在推出自己的WinForms本地化框架......
我有以下编程
Object.prototype.inherit = function(baseConstructor) {
this.prototype = (baseConstructor.prototype);
this.prototype.constructor = this;
};
Object.prototype.method = function(name, func) {
this.prototype[name] = func;
};
function StrangeArray(){}
StrangeArray.inherit(Array);
StrangeArray.method("push", function(value) {
Array.prototype.push.call(this, value);
});
var strange = new StrangeArray();
strange.push(4);
alert(strange);
Run Code Online (Sandbox Code Playgroud)
当irun它我得到堆栈溢出?为什么?
我在Windows服务中有这个:
C:/Program Files/PostgreSQL/8.4/bin/pg_ctl.exe runservice -N "postgresql-8.4" -D "D:/PostgreSQL/8.4/data" -w
Run Code Online (Sandbox Code Playgroud)
它永远不会完成执行.但是,如果我在dos shell上执行此操作:
C:/Program Files/PostgreSQL/8.4/bin/pg_ctl.exe start -N "postgresql-8.4" -D "D:/PostgreSQL/8.4/data" -w
Run Code Online (Sandbox Code Playgroud)
请注意,我只将"runservice"更改为"start",它运行正常.
任何的想法?
当我在Visual Studio(2008)内部注意到静态验证警告时,我只是在Stack Overflow上回答某人的问题:
string[] source = { "1", "A", "B" };
var sourceObjects = Array.ConvertAll(source, c => new Source(c)).ToArray();
Run Code Online (Sandbox Code Playgroud)
我收到消息需要未经证实的来源!= null.我觉得很明显,事实并非如此.这只是一个例子.另一方面,一些相当漂亮的东西似乎运作得相当好.
我正在使用1.2.20518.12版本(5月18日).我发现代码合同非常有趣,但有没有其他人有这样的案例?您是否认为当前的实现在实践中可用,或者您认为它们在这一点上纯粹是学术性的?
我把它做成了一个社区维基,但我想听听一些意见:)
所有浏览器都支持PHP的$ _SERVER ['HTTP_X_REQUESTED_WITH']吗?
您是否知道$ _SERVER ['HTTP_X_REQUESTED_WITH']不起作用的任何浏览器或时间?
类型推断的限制是什么?哪种类型的系统没有通用的推理算法?
基于Python控制台脚本为Windows开发基本图形应用程序的最佳方法是什么?如果解决方案可以作为包含该.exe文件的独立目录进行分发,那将会很棒.
我需要在我的复杂对象模型上执行深度克隆.您认为在.Net中做到这一点的最佳方式是什么?
我想到序列化/反序列化
没有必要提到MemberwiseClone不够好.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
static struct tm createDate(unsigned day, unsigned mon, int year) {
struct tm b = {0,0,0,day,mon-1,year-1900}; return b;
}
static int dateExceeded(unsigned day, unsigned mon, int year) {
struct tm b = createDate(day,mon,year);
time_t y = mktime(&b), now;
time(&now); // error C2143: syntax error : missing ';' before 'type'
double diff = difftime(y, now) / (60 * 60 * 24); // error C2065: 'diff' : undeclared identifier
return (diff < 0);
}
static void randomEvent(){ …Run Code Online (Sandbox Code Playgroud) 我想这更像是一个python问题而不是django问题,但是我无法在其他地方复制这种行为,所以我将使用不能按预期工作的确切代码.
当我找到这个工厂函数片段时,我正在研究django中的一些动态表单:
def get_employee_form(employee):
"""Return the form for a specific Board."""
employee_fields = EmployeeFieldModel.objects.filter(employee = employee).order_by ('order')
class EmployeeForm(forms.Form):
def __init__(self, *args, **kwargs):
forms.Form.__init__(self, *args, **kwargs)
self.employee = employee
def save(self):
"Do the save"
for field in employee_fields:
setattr(EmployeeForm, field.name, copy(type_mapping[field.type]))
return type('EmployeeForm', (forms.Form, ), dict(EmployeeForm.__dict__))
Run Code Online (Sandbox Code Playgroud)
[来自:http://uswaretech.com/blog/2008/10/dynamic-forms-with-django/ ]
有一点我不明白,为什么返回修改后的EmployeeForm不能解决问题? 我的意思是这样的:
def get_employee_form(employee):
#[...]same function body as before
for field in employee_fields:
setattr(EmployeeForm, field.name, copy(type_mapping[field.type]))
return EmployeeForm
Run Code Online (Sandbox Code Playgroud)
当我尝试返回修改后的类时,django忽略了我的附加字段,但返回type()的结果完美无缺.
.net ×3
c# ×3
python ×2
ajax ×1
c ×1
class ×1
clone ×1
django ×1
javascript ×1
localization ×1
php ×1
postgresql ×1
service ×1
sml ×1
srand ×1
time ×1
type-systems ×1
types ×1
windows ×1
winforms ×1