Reference a string in a resource file from another resource file

 I'm working on a website with globalization with localized resource files. My problem is, I have one string that is the same in all resource files. My question: is it possible to define this string in one (global) resource file and reference it from other resource files? Just to avoid typing the string again and again and avoid typos.


http://www.istruction.nl
0
Heleboel
4/22/2009 6:55:59 AM
asp.net.localization 2171 articles. 0 followers. Follow

6 Replies
1442 Views

Similar Articles

[PageSpeed] 49

hi, since the string is same in all resource file, you may add a new resource file in App_GlobalResources folder and reference it everywhere.
0
fatewong
4/23/2009 6:50:10 AM

 Thanks, that's a possible solution. But, if I want to concatenate this global string to another string in a resource file (not in code)? Is this possible?

The case is, I'm working on a website and every page has the name of the website in its title, along with the name of the page (the part before the minus sign is the name of the website, the part after the minus sign is the name of the page):

Website name - home

Website name - links

Website name - downloads

So, is it possible to define the Website name in the global resource file and have it concatenated to the names of the pages in the local resource pages?

Thanks in advance.


http://www.istruction.nl
0
Heleboel
4/27/2009 10:01:41 AM

hi, you may just put both global and local resource into your pages. first line below is global resource while second line is local resource.

<asp:Literal ID="ltrWebsite" runat="server" Text='<%$ Resources:MyResPrefix,Website %>'></asp:Literal>
<asp:Literal ID="ltrLocation" runat="server" meta:resourcekey="ltrLocation"></asp:Literal>

 

0
fatewong
4/28/2009 1:40:51 AM

Ok, but the title of the page is specified in the @Page directive like this:

<%@ Page Language="C#" MasterPageFile="~/xxxxxx.Master" AutoEventWireup="true" CodeBehind="links.aspx.cs" Inherits="xxxx.Website.links.links"  meta:resourcekey="PageLinks" %>
 

I do not see how I can use an <asp:Literal> in a @Page directive. Maybe it is possible to replace the

meta:resourcekey="xxx"

by

Title="<%$ Resources:MyResPrefix,WebsiteName%> - <%$ Resources:MyResPrefix,PageName%>" ?

I'll give it a try.


http://www.istruction.nl
0
Heleboel
4/28/2009 7:24:04 AM

It did not work. First of all, setting the Title attribute of the @Page directive as suggested in my previous post did not work because it is not allowed to use <%$ %> there.

My second attempt was to delete the Title attribute from the @Page directive and add a title element in the header section of the page. it did not work, too:

  <title runat="server" id="PageTitle" title="<%$ Resources:global,WebsiteName %> - <%$ Resources:PageName %>"></title>

This was because I included two <%$ %> sections in the title attribute. The parser did not accept this and throwed an exception.

When I removed the second <%$ %>, it worked, but this is not what I want. So my problem is not solved yet. Any ideas?


http://www.istruction.nl
0
Heleboel
5/1/2009 6:25:44 AM

you may use following method which put 2 literals in between <title></title> tag.

 <title><asp:Literal ID="ltrWebsite" runat="server" Text='<%$ Resources:MyRes,WebsiteName %>'/><asp:Literal ID="ltrPageName" runat="server" Text='<%$ Resources:MyRes,PageName %>'/></title>

0
fatewong
5/4/2009 4:04:07 AM
Reply:

Similar Artilces:

Accessing embeded resource (image file) from another embeded resource (Javascript file)
Hi,We have extended a control and embedded a javascript file into this dll. Within the Javascript file we access image files which is again embedded into the dll itself. Now how can I access the an embedded image from a Javascript file, where the Javascript file is also embedded? Please advice. We are using framework 3.5SreejithSreejithhttp://tips4dotnet.blogspot.com/ Try one of these links. http://aspalliance.com/726http://aspnet.4guysfromrolla.com/articles/080906-1.aspx NC......

How to use image resource in a local resource file?
Hello everyone! As the question says: The .resx files has the ability to store an image, icon, audio or any kind of files. Let's say I wanted to put a banner picture to my web page. To do this; 1) I add Default.aspx page to my web project. And put <asp:Image> control inside. So the page's code would look like this;1 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" culture="auto" uiculture="auto" %> 2 3 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 T...

Generating resource files without using resource file generator
Hi,I need to localize a ASP.net 2.0 web site but I can't  create resource files since I can't switch to design view of the web pages. The reason I can't switch to web pages is they contain lot's of html validation errors. I know I only have to correct the problems marked with "Cannot switch views" but again correcting these will take too much time, is there any way or tool to create resource files for these web pages without using VS 2005 resource file generator?Any help will save me a lot of time.  Hi,Try turning off the HTML validations momentarily in VS and turn them back on o...

Resource file from other project and localization strings
I create Class Library project for localization JS! There I've got Resource files for localization JS files are embeded resources! Everything work fine! But can I get strings from resource files by ResourceManager locating in those project for using them in codebehind? There is an article on CodeProject at http://www.codeproject.com/aspnet/SatResourcesDemo.asp Joseph GuadagnoMy Website: http://www.josephguadagno.netMy Blog - http://weblogs.asp.net/jguadagno/ If this has helped Please: Don't forget to click "Mark as Answer" on the post that helped you.That way fu...

Generating Local Resource! Folder is created! But no resource is file created!
I have a multi-project web solution! I created local resource file for first project's pages, everything's ok! But when i try to generate local resource for second resource - it only create the folder App_LocalResources and add meta to all controls in page but NOT create any resource file in App_LocalResources folder! I try all web page file in that project but App_LocalResources is still empty! Don't know why! Is there anybody faced with the same problem and find out the solution to solve this! Hi, Is this the startup project of your solution?Zhao Ji MaSincerely,Microsoft Online Communit...

superreview requested: [Bug 339843] [BeOS] mozilla/browser/app needs resource file for BeOS : [Attachment 223952] Proposed resource file
Doug Shelton <doug@sheltonfamily.org> has asked Aaron Shaver <ajshaver@comcast.net> for superreview: Bug 339843: [BeOS] mozilla/browser/app needs resource file for BeOS https://bugzilla.mozilla.org/show_bug.cgi?id=339843 Attachment 223952: Proposed resource file https://bugzilla.mozilla.org/attachment.cgi?id=223952&action=edit ...

superreview cancelled: [Bug 339843] [BeOS] mozilla/browser/app needs resource file for BeOS : [Attachment 223952] Proposed resource file
neil@parkwaycc.co.uk <neil@httl.net> has cancelled Doug Shelton <doug@sheltonfamily.org>'s request for superreview: Bug 339843: [BeOS] mozilla/browser/app needs resource file for BeOS https://bugzilla.mozilla.org/show_bug.cgi?id=339843 Attachment 223952: Proposed resource file https://bugzilla.mozilla.org/attachment.cgi?id=223952&action=edit ------- Additional Comments from neil@parkwaycc.co.uk <neil@httl.net> Platform-specific code, no superreview required. ...

superreview requested: [Bug 339843] [BeOS] mozilla/browser/app needs resource file for BeOS : [Attachment 223952] Proposed resource file #2
Doug Shelton <doug@sheltonfamily.org> has asked Mike Shaver <shaver@mozilla.org> for superreview: Bug 339843: [BeOS] mozilla/browser/app needs resource file for BeOS https://bugzilla.mozilla.org/show_bug.cgi?id=339843 Attachment 223952: Proposed resource file https://bugzilla.mozilla.org/attachment.cgi?id=223952&action=edit ...

superreview requested: [Bug 339843] [BeOS] mozilla/browser/app needs resource file for BeOS : [Attachment 223952] Proposed resource file #3
Doug Shelton <doug@sheltonfamily.org> has asked neil@parkwaycc.co.uk <neil@httl.net> for superreview: Bug 339843: [BeOS] mozilla/browser/app needs resource file for BeOS https://bugzilla.mozilla.org/show_bug.cgi?id=339843 Attachment 223952: Proposed resource file https://bugzilla.mozilla.org/attachment.cgi?id=223952&action=edit ...

Reference another resources name's value in resx files?
 hi,i'm working on a web application that supports two languages: english and german. the localisation is working fine so far.but i wonder if i could reference another resource name's value somehow. here is an example:myFile.ascx.en-US.resx currently contains:name: 123 value: one, two, threenow imagine that i add another entry in the resource file (name: 2). so the resource now contains two entries, a separate name ('2') with value ("two"), so is this possible:name: 2 value: two name: 123 value: one, [inserted value of resource name '2' here], three&nbs...

How to reference the resource file?
 I created  Web Project using VS2005. Created a folder App_GlobalResources in this project. The add a resource file Strings.resx to the folder and set property Build Action for this file as: Embedded Resource.Then I want to use this resource file with the way(ResourceManager):Assembly: The web project assembly name: MysiteResource file name: App_GlobalResources.StringsBut I always got the error as:Could not find any resources appropriate for the specified culture or the neutral culture.  Make sure "App_GlobalResources.Strings.resources" was correctly embedded or l...

Resource files but not for localization
Hi, I develop a site for multiple clients that help them run their businesses. Various labels on the site are generic e.g. Employee. Once client may call their Employees People, and another Clerks. I would like to add the ability for the client to customise these labels similar to how a resource file is used for localization. I would like the data source (whatever it may be - database, xml file etc) to be modified by the user. I give them the label, they specify their own translation. The translation they give does not have have to be in english either - i...

A File Operation Failed. Please Check Resource File Permissions So Files Can Be Edited.
When i want to add a new locale i get the following error.A File Operation Failed. Please Check Resource File Permissions So Files Can Be Edited.Anyone an idea?ThanksChristophe Goffin...

superreview requested: [Bug 339843] [BeOS] mozilla/browser/app needs resource file for BeOS : [Attachment 223953] Patch to include resource file in Makefile
Doug Shelton <doug@sheltonfamily.org> has asked Mike Shaver <shaver@mozilla.org> for superreview: Bug 339843: [BeOS] mozilla/browser/app needs resource file for BeOS https://bugzilla.mozilla.org/show_bug.cgi?id=339843 Attachment 223953: Patch to include resource file in Makefile https://bugzilla.mozilla.org/attachment.cgi?id=223953&action=edit ...

Web resources about - Reference a string in a resource file from another resource file - asp.net.localization

European Terrestrial Reference System 1989 - Wikipedia, the free encyclopedia
The European Terrestrial Reference System 1989 ( ETRS89 ) is a ECEF (Earth-Centered, Earth-Fixed) geodetic Cartesian reference frame , in which ...

New York Times Removes Reference to President Obama and Cable News
... — Noah Rothman (@NoahCRothman) December 18, 2015 The Times story was published Thursday, but by Friday morning, the reference to cable news ...

Reference Pricing tweak for Medicaid
Reference pricing is a common payment reform for commercial insurance. Common, non-urgent, deferrable procedures are prime candidates. Hip replacement ...

New Apple TV ads are clever reference to Six Colors design - Business Insider Deutschland
The new Apple TV ads are a reference to a crucial time in Apple history.

Donald Trump prompts Nazi references
Some conservatives and political commentators say the GOP frontrunner's rhetoric has crossed the line

Hillary Clinton Ends Democratic Debate With A Star Wars Reference
The other day, President Obama ended his White House press conference with a reference to The [...]

Review: Klipsch X20i Reference In-Ear Headphones
These Klipsch X20i Reference In-Ear Headphones are pretty darn fantastic, and worth every penny.`

Kentucky Grade School Scrubs All References To Christianity In ‘Charlie Brown Christmas’
Kentucky Grade School Scrubs All References To Christianity In ‘Charlie Brown Christmas’

Now you can bookmark Google image searches for later reference
Normally, image searches on Google are ephemeral things and gone the moment you close the browser tab. However, a new feature on the search giant's ...

How To Get the References You Need For the Job You Really Want
How To Get the References You Need For the Job You Really Want

Resources last updated: 12/30/2015 12:32:51 AM