While translating the application in Japanese language, I got following error:
I18n::MissingTranslationData in Campaigns#campaign_upload
Showing C:/projects/demoapp/app/views/campaigns/_update_uploads.html.erb where line #20 raised:
translation missing: ja, number, human, storage_units, format
For line:
<%=number_to_human_size(asset.attachment_file_size)%>
Error displays that some translation is missing for ja, number, human, storage_units, format.
To fix the error:
Changed the code in view to include locale params:
Added following codes in config\locales\ja.yml file :
Changed the code in view to include locale params:
<%=number_to_human_size(asset.attachment_file_size, :locale=>I18n.locale)%>
Added following codes in config\locales\ja.yml file :
ja:
number:
format:
separator: "."
delimiter: ","
precision: 3
significant: false
strip_insignificant_zeros: false
# Used in number_to_human_size() and number_to_human()
human:
format:
delimiter: ""
precision: 3
significant: true
strip_insignificant_zeros: true
# Used in number_to_human_size()
storage_units:
format: "%n %u"
units:
byte:
one: "Byte"
other: "Bytes"
kb: "KB"
mb: "MB"
gb: "GB"
tb: "TB"
# Used in number_to_human()
decimal_units:
format: "%n %u"
units:
# femto: Quadrillionth
# pico: Trillionth
# nano: Billionth
# micro: Millionth
# mili: Thousandth
# centi: Hundredth
# deci: Tenth
unit: ""
# ten:
# one: Ten
# other: Tens
# hundred: Hundred
thousand: Thousand
million: Million
billion: Billion
trillion: Trillion
quadrillion: Quadrillion
number:
format:
separator: "."
delimiter: ","
precision: 3
significant: false
strip_insignificant_zeros: false
# Used in number_to_human_size() and number_to_human()
human:
format:
delimiter: ""
precision: 3
significant: true
strip_insignificant_zeros: true
# Used in number_to_human_size()
storage_units:
format: "%n %u"
units:
byte:
one: "Byte"
other: "Bytes"
kb: "KB"
mb: "MB"
gb: "GB"
tb: "TB"
# Used in number_to_human()
decimal_units:
format: "%n %u"
units:
# femto: Quadrillionth
# pico: Trillionth
# nano: Billionth
# micro: Millionth
# mili: Thousandth
# centi: Hundredth
# deci: Tenth
unit: ""
# ten:
# one: Ten
# other: Tens
# hundred: Hundred
thousand: Thousand
million: Million
billion: Billion
trillion: Trillion
quadrillion: Quadrillion
Although the above codes are in English language, you can get the above code in Japanese or any other languages also, which will fix number_to_human_size error..
No comments:
Post a Comment