| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Helper tool that is built and run during a build to pull strings from | 5 // Helper tool that is built and run during a build to pull strings from |
| 6 // the GRD files and generate the InfoPlist.strings files needed for | 6 // the GRD files and generate the InfoPlist.strings files needed for |
| 7 // Mac OS X app bundles. | 7 // Mac OS X app bundles. |
| 8 | 8 |
| 9 #import <Foundation/Foundation.h> | 9 #import <Foundation/Foundation.h> |
| 10 | 10 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 } | 69 } |
| 70 | 70 |
| 71 return resource_pack; | 71 return resource_pack; |
| 72 } | 72 } |
| 73 | 73 |
| 74 NSString* LoadStringFromDataPack(base::DataPack* data_pack, | 74 NSString* LoadStringFromDataPack(base::DataPack* data_pack, |
| 75 const char* data_pack_lang, | 75 const char* data_pack_lang, |
| 76 uint32_t resource_id, | 76 uint32_t resource_id, |
| 77 const char* resource_id_str) { | 77 const char* resource_id_str) { |
| 78 NSString* result = nil; | 78 NSString* result = nil; |
| 79 StringPiece data; | 79 base::StringPiece data; |
| 80 if (data_pack->Get(resource_id, &data)) { | 80 if (data_pack->Get(resource_id, &data)) { |
| 81 // Data pack encodes strings as UTF16. | 81 // Data pack encodes strings as UTF16. |
| 82 result = | 82 result = |
| 83 [[[NSString alloc] initWithBytes:data.data() | 83 [[[NSString alloc] initWithBytes:data.data() |
| 84 length:data.length() | 84 length:data.length() |
| 85 encoding:NSUTF16LittleEndianStringEncoding] | 85 encoding:NSUTF16LittleEndianStringEncoding] |
| 86 autorelease]; | 86 autorelease]; |
| 87 } | 87 } |
| 88 if (!result) { | 88 if (!result) { |
| 89 fprintf(stderr, "ERROR: failed to load string %s for lang %s\n", | 89 fprintf(stderr, "ERROR: failed to load string %s for lang %s\n", |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 [output_path stringByAppendingPathComponent:@"InfoPlist.strings"]; | 291 [output_path stringByAppendingPathComponent:@"InfoPlist.strings"]; |
| 292 if (![strings_file_contents_utf8 writeToFile:output_path | 292 if (![strings_file_contents_utf8 writeToFile:output_path |
| 293 atomically:YES]) { | 293 atomically:YES]) { |
| 294 fprintf(stderr, "ERROR: Failed to write out '%s'\n", | 294 fprintf(stderr, "ERROR: Failed to write out '%s'\n", |
| 295 [output_path UTF8String]); | 295 [output_path UTF8String]); |
| 296 exit(1); | 296 exit(1); |
| 297 } | 297 } |
| 298 } | 298 } |
| 299 return 0; | 299 return 0; |
| 300 } | 300 } |
| OLD | NEW |