OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include <stdint.h> | 10 #include <stdint.h> |
11 #include <stdio.h> | 11 #include <stdio.h> |
12 #include <unistd.h> | 12 #include <unistd.h> |
13 | 13 |
14 #include <memory> | 14 #include <memory> |
15 | 15 |
16 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
17 #include "base/files/file_util.h" | 17 #include "base/files/file_util.h" |
18 #include "base/i18n/message_formatter.h" | |
18 #include "base/mac/scoped_nsautorelease_pool.h" | 19 #include "base/mac/scoped_nsautorelease_pool.h" |
19 #include "base/strings/string_number_conversions.h" | |
20 #include "base/strings/string_piece.h" | 20 #include "base/strings/string_piece.h" |
21 #include "base/strings/string_util.h" | 21 #include "base/strings/string_util.h" |
22 #include "base/strings/string_util.h" | 22 #include "base/strings/string_util.h" |
23 #include "base/strings/sys_string_conversions.h" | 23 #include "base/strings/sys_string_conversions.h" |
24 #include "chrome/grit/chromium_strings.h" | 24 #include "chrome/grit/chromium_strings.h" |
25 #include "ui/base/resource/data_pack.h" | 25 #include "ui/base/resource/data_pack.h" |
26 | 26 |
27 namespace { | 27 namespace { |
28 | 28 |
29 NSString* ApplicationVersionString(const char* version_file_path) { | 29 NSString* ApplicationVersionString(const char* version_file_path) { |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
250 short_name_id, short_name_id_str); | 250 short_name_id, short_name_id_str); |
251 NSString* copyright_format = | 251 NSString* copyright_format = |
252 LoadStringFromDataPack(branded_data_pack.get(), cur_lang, | 252 LoadStringFromDataPack(branded_data_pack.get(), cur_lang, |
253 IDS_ABOUT_VERSION_COPYRIGHT, | 253 IDS_ABOUT_VERSION_COPYRIGHT, |
254 "IDS_ABOUT_VERSION_COPYRIGHT"); | 254 "IDS_ABOUT_VERSION_COPYRIGHT"); |
255 NSString* address_book_prompt_description = | 255 NSString* address_book_prompt_description = |
256 LoadStringFromDataPack(branded_data_pack.get(), cur_lang, | 256 LoadStringFromDataPack(branded_data_pack.get(), cur_lang, |
257 IDS_AUTOFILL_ADDRESS_BOOK_PROMPT_DESCRIPTION, | 257 IDS_AUTOFILL_ADDRESS_BOOK_PROMPT_DESCRIPTION, |
258 "IDS_AUTOFILL_ADDRESS_BOOK_PROMPT_DESCRIPTION"); | 258 "IDS_AUTOFILL_ADDRESS_BOOK_PROMPT_DESCRIPTION"); |
259 | 259 |
260 base::Time::Exploded exploded_time; | |
261 base::Time::Now().LocalExplode(&exploded_time); | |
262 std::vector<base::string16> replacements; | |
263 replacements.push_back(base::IntToString16(exploded_time.year)); | |
264 NSString* copyright = base::SysUTF16ToNSString( | 260 NSString* copyright = base::SysUTF16ToNSString( |
265 base::ReplaceStringPlaceholders( | 261 base::i18n::MessageFormatter::FormatWithNumberedArgs( |
266 base::SysNSStringToUTF16(copyright_format), replacements, NULL)); | 262 copyright_format, base::Time::Now())); |
jungshik at Google
2016/05/25 09:09:36
This should be |base::SysNSStringToUTF16(copyright
Greg Levin
2016/05/26 15:25:58
Done.
| |
267 | 263 |
268 // For now, assume this is ok for all languages. If we need to, this could | 264 // For now, assume this is ok for all languages. If we need to, this could |
269 // be moved into generated_resources.grd and fetched. | 265 // be moved into generated_resources.grd and fetched. |
270 NSString *get_info = [NSString stringWithFormat:@"%@ %@, %@", | 266 NSString *get_info = [NSString stringWithFormat:@"%@ %@, %@", |
271 name, version_string, copyright]; | 267 name, version_string, copyright]; |
272 | 268 |
273 // Generate the InfoPlist.strings file contents | 269 // Generate the InfoPlist.strings file contents |
274 NSString* strings_file_contents_string = | 270 NSString* strings_file_contents_string = |
275 [NSString stringWithFormat: | 271 [NSString stringWithFormat: |
276 @"CFBundleDisplayName = \"%@\";\n" | 272 @"CFBundleDisplayName = \"%@\";\n" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
326 [output_path stringByAppendingPathComponent:@"InfoPlist.strings"]; | 322 [output_path stringByAppendingPathComponent:@"InfoPlist.strings"]; |
327 if (![strings_file_contents_utf8 writeToFile:output_path | 323 if (![strings_file_contents_utf8 writeToFile:output_path |
328 atomically:YES]) { | 324 atomically:YES]) { |
329 fprintf(stderr, "ERROR: Failed to write out '%s'\n", | 325 fprintf(stderr, "ERROR: Failed to write out '%s'\n", |
330 [output_path UTF8String]); | 326 [output_path UTF8String]); |
331 exit(1); | 327 exit(1); |
332 } | 328 } |
333 } | 329 } |
334 return 0; | 330 return 0; |
335 } | 331 } |
OLD | NEW |