Culture-specific file size units ("KB" vs. "Koctets") ?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

(If this is not posted in the right place, please let me know what the right
place is...)
I understand that French Windows Explorer uses "Ko" as the file size units
where English would use "KB". My C# application is going to display file
sizes and I would like it to use the correct string based on the user's
locale. Is there any way to get the correct string "Ko/KB/whatever" from
..NET or Windows?

-Russ
 
Russ,

Just an idea, why not ask this in a French newsgroup, they will answer you
probably directly even if you do it in English and excuse yourself for that.

Octet is of course a byte (8bits)

Cor
 
Not sure to understand the exact problem. Did you see what .NET offers for
application localization ? I would include these strings as resources in my
own application.The resource will be selected based on the language.

Do you have only this string to localize ?

Patrice
 
The application has lots of other strings to localize and we are already
using string resources which .NET retrieves based on culture. Certainly I
can include these strings in that way. I just thought it would be even
better if there was a way to somehow retrieve a string for file size units
from the environment somehow. After some looking I could not find such a way
-- but I thought I would ask the group if there was indeed a way to do that.
Maybe there isn't.
 
Russ,

I think that is not important, however you can take the program language you
use
something as

microsoft.public.fr.dotnet.csharp
or just
microsoft.public.fr.dotnet

Cor
 
Russ,
I don't know of a function to retrieve the information from Windows.

However you could set up a "string table" resource that you then localize.
Every place you need the string, you would retrieve the string wanted from
the resource.

Here are some MSDN articles that should get you started:

http://msdn.microsoft.com/library/d...n-us/vbcon/html/vboriInternationalization.asp

http://msdn.microsoft.com/library/d.../cpguide/html/cpconcreatingusingresources.asp

The directory structure itself is shown at the bottom of:

http://msdn.microsoft.com/library/d...ide/html/cpconcreatingsatelliteassemblies.asp

When you use VS.NET to create your international resources VS.NET create the
folder structure needed in the bin (output) folder.

I normally use .resx files with VS.NET...

Hope this helps
Jay
 
I understand that French Windows Explorer uses "Ko" as the file size units
where English would use "KB". My C# application is going to display file
sizes and I would like it to use the correct string based on the user's
locale. Is there any way to get the correct string "Ko/KB/whatever" from
.NET or Windows?

There are a few Win32 APIs for formatting file sizes;
StrFormatByteSize* for returning the size scaled to the "best" 1024
multiple, or StrFormatKBSize if you always want the unit to be KB.

http://msdn.microsoft.com/library/e...erence/shlwapi/string/strformatbytesize64.asp
http://msdn.microsoft.com/library/e.../reference/shlwapi/string/strformatkbsize.asp

If you prefer to roll your own algorithm and just need the string,
these are available as string resources 259 - 265 in Shlwapi.dll. I
assume these are localized appropriately, but I don't have a french
system to verify it on.



Mattias
 
My personal preference would be still to keep this string in my own
resources :
- simplicity, I don't feel really clean to use resources for all except this
one (plus it could change, break or whetever)
- you could have an inconsistent UI ie. having the size units localized but
all else using the default language (if you have no translations for this
particular language).

Patrice
--
 
Back
Top