Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(431)

Side by Side Diff: chrome/tools/mac_helpers/infoplist_strings_util.mm

Issue 1996993002: i18n of Copyright line to use locally correct numeric glyphs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add time.h includes, as per review (also merge) Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/tools/mac_helpers/BUILD.gn ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/time/time.h"
24 #include "chrome/grit/chromium_strings.h" 25 #include "chrome/grit/chromium_strings.h"
25 #include "ui/base/resource/data_pack.h" 26 #include "ui/base/resource/data_pack.h"
26 27
27 namespace { 28 namespace {
28 29
29 NSString* ApplicationVersionString(const char* version_file_path) { 30 NSString* ApplicationVersionString(const char* version_file_path) {
30 NSError* error = nil; 31 NSError* error = nil;
31 NSString* path_string = [NSString stringWithUTF8String:version_file_path]; 32 NSString* path_string = [NSString stringWithUTF8String:version_file_path];
32 NSString* version_file = 33 NSString* version_file =
33 [NSString stringWithContentsOfFile:path_string 34 [NSString stringWithContentsOfFile:path_string
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 short_name_id, short_name_id_str); 251 short_name_id, short_name_id_str);
251 NSString* copyright_format = 252 NSString* copyright_format =
252 LoadStringFromDataPack(branded_data_pack.get(), cur_lang, 253 LoadStringFromDataPack(branded_data_pack.get(), cur_lang,
253 IDS_ABOUT_VERSION_COPYRIGHT, 254 IDS_ABOUT_VERSION_COPYRIGHT,
254 "IDS_ABOUT_VERSION_COPYRIGHT"); 255 "IDS_ABOUT_VERSION_COPYRIGHT");
255 NSString* address_book_prompt_description = 256 NSString* address_book_prompt_description =
256 LoadStringFromDataPack(branded_data_pack.get(), cur_lang, 257 LoadStringFromDataPack(branded_data_pack.get(), cur_lang,
257 IDS_AUTOFILL_ADDRESS_BOOK_PROMPT_DESCRIPTION, 258 IDS_AUTOFILL_ADDRESS_BOOK_PROMPT_DESCRIPTION,
258 "IDS_AUTOFILL_ADDRESS_BOOK_PROMPT_DESCRIPTION"); 259 "IDS_AUTOFILL_ADDRESS_BOOK_PROMPT_DESCRIPTION");
259 260
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( 261 NSString* copyright = base::SysUTF16ToNSString(
265 base::ReplaceStringPlaceholders( 262 base::i18n::MessageFormatter::FormatWithNumberedArgs(
266 base::SysNSStringToUTF16(copyright_format), replacements, NULL)); 263 base::SysNSStringToUTF16(copyright_format), base::Time::Now()));
267 264
268 // For now, assume this is ok for all languages. If we need to, this could 265 // For now, assume this is ok for all languages. If we need to, this could
269 // be moved into generated_resources.grd and fetched. 266 // be moved into generated_resources.grd and fetched.
270 NSString *get_info = [NSString stringWithFormat:@"%@ %@, %@", 267 NSString *get_info = [NSString stringWithFormat:@"%@ %@, %@",
271 name, version_string, copyright]; 268 name, version_string, copyright];
272 269
273 // Generate the InfoPlist.strings file contents 270 // Generate the InfoPlist.strings file contents
274 NSString* strings_file_contents_string = 271 NSString* strings_file_contents_string =
275 [NSString stringWithFormat: 272 [NSString stringWithFormat:
276 @"CFBundleDisplayName = \"%@\";\n" 273 @"CFBundleDisplayName = \"%@\";\n"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 [output_path stringByAppendingPathComponent:@"InfoPlist.strings"]; 323 [output_path stringByAppendingPathComponent:@"InfoPlist.strings"];
327 if (![strings_file_contents_utf8 writeToFile:output_path 324 if (![strings_file_contents_utf8 writeToFile:output_path
328 atomically:YES]) { 325 atomically:YES]) {
329 fprintf(stderr, "ERROR: Failed to write out '%s'\n", 326 fprintf(stderr, "ERROR: Failed to write out '%s'\n",
330 [output_path UTF8String]); 327 [output_path UTF8String]);
331 exit(1); 328 exit(1);
332 } 329 }
333 } 330 }
334 return 0; 331 return 0;
335 } 332 }
OLDNEW
« no previous file with comments | « chrome/tools/mac_helpers/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698