0

プロジェクトのローカリゼーションの最終段階を完了しています。翻訳されたテキストが .txt 形式と .docx 形式に分かれて戻ってきました。

一度入力した .txt はlocalizable.strings正常に機能しますが、Word 文書からコピーしたものは機能しません。

これは私がこれまでに試したことです:

  • .docx を .txt として保存し、単語をエンコードします
  • .txt を韓国語 (Mac OS X) として保存し、このテキストを XCode にコピーして韓国語 (Mac OS X) として再解釈し、utf-16 に変換します。

utf-16 に変換するために多くのオプションを試しましたが、クラックできないようです。どんなアイデアでも大歓迎です。

以下は、ローカライズされたヘルプ ビューの実装です。

helpText = [NSArray arrayWithObjects:
                [NSDictionary dictionaryWithObjectsAndKeys:
                 NSLocalizedString(@"    The Actions Tab", nil), kHelpTextKeyString,
                 @"Arial", kHelpTextKeyFontName,
                 [NSNumber numberWithInt:20], kHelpTextKeyFontSize,
                 [[UIColor blackColor] CGColor], kHelpTextKeyColor,
                 CGRectCreateDictionaryRepresentation(CGRectMake(30.0, 55.0, 200.0, 28.0)), kHelpTextKeyRect,
                 nil],
                [NSDictionary dictionaryWithObjectsAndKeys:
                 [NSArray arrayWithObjects:
                  NSLocalizedString(@"

- (void)displaySelectedHelpImage:(UIImage *)orgImage withTextArray:(NSArray *)textArr {
CGImageRef cgImage = [orgImage CGImage];
int pixelsWide              = CGImageGetWidth(cgImage);
int pixelsHigh              = CGImageGetHeight(cgImage);
int bitsPerComponent        = CGImageGetBitsPerComponent(cgImage);//8; // fixed
int bitsPerPixel            = CGImageGetBitsPerPixel(cgImage);//bitsPerComponent * numberOfCompnent;
int bytesPerRow             = CGImageGetBytesPerRow(cgImage);//(pixelsWide * bitsPerPixel) // 8; // bytes
int byteCount               = (bytesPerRow * pixelsHigh);
CGColorSpaceRef colorSpace  = CGImageGetColorSpace(cgImage);//CGColorSpaceCreateDeviceRGB();

// Allocate data
NSMutableData *data = [NSMutableData dataWithLength:byteCount];
// Create a bitmap context
CGContextRef context = CGBitmapContextCreate([data mutableBytes], pixelsWide, pixelsHigh, bitsPerComponent, bytesPerRow, colorSpace, kCGImageAlphaPremultipliedLast); //kCGImageAlphaPremultipliedLast);//kCGImageAlphaNoneSkipLast); //kCGImageAlphaOnly);
// Set the blend mode to copy to avoid any alteration of the source data or to invert to invert image
CGContextSetBlendMode(context, kCGBlendModeCopy);
// Set alpha
CGContextSetAlpha(context, 1.0);
// Color image
//CGContextSetRGBFillColor(context, 1 ,1, 1, 1.0);
//CGContextFillRect(context, CGRectMake(0.0, 0.0, pixelsWide, pixelsHigh));
// Draw the image to extract the alpha channel
CGContextDrawImage(context, CGRectMake(0.0, 0.0, pixelsWide, pixelsHigh), cgImage);

// add text to image
// Changes the origin of the user coordinate system in a context
//CGContextTranslateCTM (context, pixelsWide, pixelsHigh);
// Rotate context upright
//CGContextRotateCTM (context, -180. *  M_PI/180);
for (NSDictionary *dic in textArr) {

    CGContextSelectFont (context,
                         //todo
                         [[dic objectForKey:kHelpTextKeyFontName] UTF8String],
                         [[dic objectForKey:kHelpTextKeyFontSize] intValue],
                         kCGEncodingMacRoman);
    CGContextSetCharacterSpacing (context, 2);
    CGContextSetTextDrawingMode (context, kCGTextFillStroke);

    CGColorRef color = (CGColorRef)[dic objectForKey:kHelpTextKeyColor];
    CGRect rect;
    CGRectMakeWithDictionaryRepresentation((CFDictionaryRef)[dic objectForKey:kHelpTextKeyRect], &rect);

    CGContextSetFillColorWithColor(context, color);
    CGContextSetStrokeColorWithColor(context, color); 

    if ([[dic objectForKey:kHelpTextKeyString] isKindOfClass:[NSArray class]]) {
        for (NSString *str in [dic objectForKey:kHelpTextKeyString]) {
            CGContextShowTextAtPoint(context,
                                     rect.origin.x,
                                     pixelsHigh - rect.origin.y,
                                     [str cStringUsingEncoding:[NSString defaultCStringEncoding]],
                                     [str length]);
            rect.origin.y += [[dic objectForKey:kHelpTextKeyFontSize] intValue];
        }
4

2 に答える 2

1

この問題に直面している人にとっては、coretext 基礎クラスを使用することで解決されました。

于 2012-03-18T12:33:50.150 に答える
0

Word 文書には何が含まれていますか? 「うまくいかない」とはどういう意味ですか?

それらに文字列が含まれている場合、それらを既存の localizable.strings ファイルに単純に追加できませんか? それが機能するため、このファイルにはエンコードの問題がないため、Word から XCode の localizable.strings ファイルにコピーして貼り付けることができます。

于 2012-03-05T11:27:28.477 に答える