在我的iPhone应用程序中,我需要显示对象计数然后我本地化,因为英语区分单数和复数,我做以下
//伪代码
if (objectList.count == 1)
{
NSLog(@"%@", NSLocalizedString(@"1 object", @"display one objects");
}
else
{
NSLog(@"%@", NSLocalizedString(@"%d objects", @"display multiple objects");
}
这适用于英语,但在许多其他语言中,复数形式的名词不是简单地通过添加's'来构造的.
正如本页所解释的,语言之间有两点不同:
- 复数形式如何构建的形式不同.这是具有许多不规则性的语言的问题.例如,德国就是一个极端的案例.虽然英语和德语是同一语系(日耳曼语)的一部分,但在德语中很难找到几乎常规的复数名词形式(附加's').
- 复数形式的数量不同.对于那些只有罗马语和日耳曼语经验的人来说,这有点令人惊讶,因为这里的数字是相同的(有两个).
我应该如何在我的代码中处理这个问题?
我想要实现的是这样的:
class object:
def __init__(self):
WidthVariable(self)
print self.width
#Imagine I did this 60frames/1second later
print self.width
#output:
>>0
>>25
Run Code Online (Sandbox Code Playgroud)
我想要发生的事情(如上所述):WidthVariable创建类时,它将变量添加width到对象实例。该变量的行为类似于常规属性,但是在这种特殊情况下,它是只读的(仅fget设置了变量)。另外,fget调用定义的函数WidthVariable决定width返回什么。
但是,我不知道该怎么做!我使用常规属性进行了尝试,但发现它们仅适用于类,而不适用于每个实例-请注意,我使用的代码应与上述代码尽可能相似(即,__init__of中的代码WidthVariable应设置width变量,而无其他地方) 。而且,self.width不能成为函数,因为我没有self.width()想要的名字self.width(因为它与我拥有的其余设计保持一致)。
需要说明的是,完整的代码如下所示:
class MyObject:
def __init__(self)
WidthVariable(self)
print self.width
class WidthVariable:
def __init__(self, object)
object.width = property(self.get_width)
def get_width(self):
value = #do_stuff
return value #The Value
#output:
>>25 #Whatever the Value was
Run Code Online (Sandbox Code Playgroud) 我有以下字符串:
"Test, User" < test@test.com >, "Another, Test" < another@test.com >, .........
Run Code Online (Sandbox Code Playgroud)
我想要以下结果:
array(
array('name' => 'Test, User', 'email' => 'test@test.com'),
array('name' => 'Another, Test', 'email' => 'another@test.com'),
...........
)
Run Code Online (Sandbox Code Playgroud) 我正在考虑为Ruby on Rails构建一个登录系统,就像这个一样
http://visionmasterdesigns.com/tutorial-create-a-login-system-in-ruby-on-rails/
在安全性方面,如果用户的用户名错误,我是否应该限制用户登录的尝试?
此外,登录的基本步骤似乎是:
还有什么我应该考虑的吗?
我正在尝试使用gcc在我的Linux(Ubuntu 8.04)中编译zpipe.c示例,但是我遇到了一些错误,请看一下:
[ubuntu@eeepc:~/Desktop] gcc zpipe.c
/tmp/ccczEQxz.o: In function `def':
zpipe.c:(.text+0x65): undefined reference to `deflateInit_'
zpipe.c:(.text+0xd3): undefined reference to `deflateEnd'
zpipe.c:(.text+0x150): undefined reference to `deflate'
zpipe.c:(.text+0x1e8): undefined reference to `deflateEnd'
zpipe.c:(.text+0x27b): undefined reference to `deflateEnd'
/tmp/ccczEQxz.o: In function `inf':
zpipe.c:(.text+0x314): undefined reference to `inflateInit_'
zpipe.c:(.text+0x382): undefined reference to `inflateEnd'
zpipe.c:(.text+0x3d7): undefined reference to `inflate'
zpipe.c:(.text+0x44b): undefined reference to `inflateEnd'
zpipe.c:(.text+0x4c1): undefined reference to `inflateEnd'
zpipe.c:(.text+0x4f6): undefined reference to `inflateEnd'
collect2: ld returned 1 exit status
[ubuntu@eeepc:~/Desktop]
Run Code Online (Sandbox Code Playgroud)
请记住,我已正确安装zLib-dev,但为什么我会收到此错误?
我按照如何:向WPF应用程序添加启动画面中概述的简单步骤,为我的WPF应用程序添加启动画面.当我启动应用程序时,会显示启动图像,然后弹出主窗口,并且启动图像会消失.
我的问题是,当弹出主窗口时,它会出现在初始图像的顶部.然后,当启动图像开始淡出时,启动图像会再次弹出到顶部.最终结果是,当主窗口出现时,启动图像会瞬间消失.
如何强制主窗口出现在启动图像下,以便启动图像不会消失?
我正在写一个小的python脚本,它将从我正在运行的Windows的VM中获取信息.
目前,我可以使用以下方法在32位XP机器上列出进程:
http://code.activestate.com/recipes/305279/
是否有可能以某种方式检测运行的Windows版本并执行另一种方法来获取64位机器上的进程,我试图从64位Vista和64位Windows 7获取进程.
有任何想法吗?
我有一项服务需要每5分钟更新一次注册表(抵消gpo).代码在常规应用程序中运行良好,但是当我将它放在Windows服务中时,它不会进行更改.我使用本地系统帐户进行服务,并没有抛出任何异常
以下代码适用于常规控制台应用,但不适用于服务:
RegistryKey key = Registry.CurrentUser.OpenSubKey("Control Panel\\Desktop", true);
if (key != null)
{
key.SetValue("ScreenSaverIsSecure", "0", RegistryValueKind.String);
key.SetValue("ScreenSaveActive", "0", RegistryValueKind.String);
key.SetValue("ScreenSaveTimeOut", "0", RegistryValueKind.String);
key.SetValue("SCRNSAVE.EXE", "", RegistryValueKind.String);
}
key = Registry.CurrentUser.OpenSubKey(@"Software\Policies\Microsoft\Windows\Control Panel\Desktop", true);
if (key != null)
{
key.SetValue("ScreenSaverIsSecure", "0", RegistryValueKind.String);
key.SetValue("ScreenSaveActive", "0", RegistryValueKind.String);
key.SetValue("ScreenSaveTimeOut", "0", RegistryValueKind.String);
key.SetValue("SCRNSAVE.EXE", "", RegistryValueKind.String);
}
System.Diagnostics.Process.Start(@"c:\windows\System32\RUNDLL32.EXE", "user32.dll, UpdatePerUserSystemParameters");
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
编辑:
谢谢你的回复.我不知道为什么"CurrentUser"无法引起我的注意.感谢您指出了这一点.
我的问题仍然是组策略正在被当前用户推动.现在我正在考虑创建一个在启动时加载并保持活动状态的应用程序.欢迎任何其他建议.
编辑:
至于Will的评论,我无法在win32 api中找到UpdatePerUserSystemParameters函数签名.这是否意味着可以在没有参数的情况下调用它?
[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern bool UpdatePerUserSystemParameters();
Run Code Online (Sandbox Code Playgroud) 我需要将底部16行从文本文件复制到另一个文本文件.我需要为所有客户端执行此过程.在客户端的位置,文本文件将是常见的,但是底部16行对于确认包安装很重要.
我在使用 GridView 作为 ListView 的视图时遇到问题,我想要做的是当用户从 Gridview 中的组合框中进行选择时触发一个事件,并在事件中传递所选项目。
谢谢
c# ×2
python ×2
wpf ×2
batch-file ×1
c ×1
combobox ×1
compression ×1
gridview ×1
iphone ×1
localization ×1
login ×1
php ×1
process ×1
properties ×1
python-2.6 ×1
regex ×1
registry ×1
selecteditem ×1
windows ×1
zlib ×1