@@ -19,7 +19,7 @@ class L10nHelper
19
19
# - `nil` if the file does not exist or is neither of those format (e.g. not a `.strings` file at all)
20
20
#
21
21
def self . strings_file_type ( path :)
22
- return :text if File . exist ?( path ) && File . size ( path ) . zero? # If completely empty file, consider it as a valid `.strings` files in textual format
22
+ return :text if File . empty ?( path ) # If completely empty file, consider it as a valid `.strings` files in textual format
23
23
24
24
# Start by checking it seems like a valid property-list file (and not e.g. an image or plain text file)
25
25
_ , status = Open3 . capture2 ( '/usr/bin/plutil' , '-lint' , path )
@@ -57,7 +57,7 @@ def self.merge_strings(paths:, output_path:)
57
57
58
58
tmp_file . write ( "/* Generated File. Do not edit. */\n \n " )
59
59
paths . each do |input_file , prefix |
60
- next if File . exist ?( input_file ) && File . size ( input_file ) . zero? # Accept but skip existing- but- totally- empty files ( to avoid adding useless `MARK:` comment for them)
60
+ next if File . empty ?( input_file ) # Skip existing but totally empty files, to avoid adding useless `MARK:` comment for them
61
61
62
62
fmt = strings_file_type ( path : input_file )
63
63
raise "The file `#{ input_file } ` does not exist or is of unknown format." if fmt . nil?
@@ -94,7 +94,7 @@ def self.merge_strings(paths:, output_path:)
94
94
# @raise [RuntimeError] If the file is not a valid strings file or there was an error in parsing its content.
95
95
#
96
96
def self . read_strings_file_as_hash ( path :)
97
- return { } if File . exist ?( path ) && File . size ( path ) . zero? # Return empty hash if completely empty file
97
+ return { } if File . empty ?( path ) # Return empty hash if completely empty file
98
98
99
99
output , status = Open3 . capture2e ( '/usr/bin/plutil' , '-convert' , 'json' , '-o' , '-' , path )
100
100
raise output unless status . success?
0 commit comments