JamesBrownIsDead
JamesBrownIsDead

Reputation: 57

ASP.NET localized files

I've got a web page with a link, and the link is suppose to correspond to a PDF is the given user's language. I'm wondering where I should put these PDF files though. If I put them in App_LocalResources, I can't specify a link to /App_LocalResources/TOS_en-US.pdf can I?

Upvotes: 3

Views: 276

Answers (3)

Eilon
Eilon

Reputation: 25704

The PDF should definitely not be in the App_LocalResources folder. That folder is only for RESX files.

The PDF files can go anywhere else in your app. For example, a great place to put them would be in a ~/PDF folder. Then your links will have to be dynamically generated (similar to what Greg has shown):

string cultureSpecificFileName = String.Format("TOS_{0}.pdf", CultureInfo.CurrentCulture.Name);

However, there are some other things to consider:

  1. You need a way to ensure that you actually have a PDF for the given language. If someone shows up at your site and has their culture specified as Klingon, it's unlikely that you have such a PDF.
  2. You need to decide exactly what the file format will be. In the example given, the file would have to be named TOS_en-US.pdf. It you want to use the 2-letter ISO culture names, use CurrentCulture.TwoLetterISOLanguageName and then the file name would be TOS_en.pdf.

Upvotes: 1

Sonny Boy
Sonny Boy

Reputation: 8016

Does the PDF have to have the same file name for each of the different languages? If not, put them all into a directory and just store the path in your resources file.

Upvotes: 0

Greg
Greg

Reputation: 16680

I would store the filename somewhere with an argument in it (i.e. "TOS_{0}.pdf" ) and then just add the appropriate suffix in code:

string cultureSpecificFileName = string.Format("TOS_{0}.pdf", CultureInfo.CurrentCulture);

Upvotes: 0

Related Questions