@T("ShoppingCart.CartIsEmpty")

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
11 years ago
Hi all,

can anyone explain this line to me please?

Is "T" a function defined by NC?

I am assuming that "ShoppingCart.CartIsEmpty" is a string that is reading from a Resources file. Where is such a file?

Thanks.
11 years ago
LAM-ECOM wrote:
Hi all,

can anyone explain this line to me please?

Is "T" a function defined by NC?

I am assuming that "ShoppingCart.CartIsEmpty" is a string that is reading from a Resources file. Where is such a file?

Thanks.


I'm guess you found that in a .cshtml file but you don't say where you found it or what version of nop you are in.

It's MVC for text I think and prints the contents of ShoppingCart.CartIsEmpty

ShoppingCart being the model and CartIsEmpty being the property on the model

HTH

Dave
11 years ago
daveb wrote:
Hi all,

can anyone explain this line to me please?

Is "T" a function defined by NC?

I am assuming that "ShoppingCart.CartIsEmpty" is a string that is reading from a Resources file. Where is such a file?

Thanks.

I'm guess you found that in a .cshtml file but you don't say where you found it or what version of nop you are in.

It's MVC for text I think and prints the contents of ShoppingCart.CartIsEmpty

ShoppingCart being the model and CartIsEmpty being the property on the model

HTH

Dave


Hi daveb,

I did not mention the file I found it because I thought it did not matter much. Either way, I found it in OrderSummary.cshtml

The version of NC I am currently working on is 2.50

You are right. It is MVC code, and it does print the contents of ShoppingCart.CartIsEmpty. However, my question was more related towards "what is @T()?", Why they make this call to return a string? and finally, how/where i can modify that string?

I am assuming the string is coming from a "resource" file? Is this modifiable via the admin section?

Thanks for your help.


.
11 years ago
@T(..) is just an HTML helper to return a localized string. It returns not just a string but an IHtmlString (eg. an HTML encoded string). see _localizationService.GetResource()
11 years ago
See now I can see the thing in the code I realise that the previous info is incorrect.

Always provide as much information as possible, that way people don't have to waste time asking you what you're going on about.

Yeah ShoppingCart.CartIsEmpty is a localised string resource located in table LocaleStringResource

you can access it from the admin via

Configuration - Languages - View string resources (for relevant language)

Use the filter on Resource Name to get to ShoppingCart.CartIsEmpty and edit away :)

I'm still rubbish at MVC
11 years ago
keesjan wrote:
@T(..) is just an HTML helper to return a localized string. It returns not just a string but an IHtmlString (eg. an HTML encoded string). see _localizationService.GetResource()


Thanks a lot for your insight!
11 years ago
daveb wrote:
See now I can see the thing in the code I realise that the previous info is incorrect.

Always provide as much information as possible, that way people don't have to waste time asking you what you're going on about.

Yeah ShoppingCart.CartIsEmpty is a localised string resource located in table LocaleStringResource

you can access it from the admin via

Configuration - Languages - View string resources (for relevant language)

Use the filter on Resource Name to get to ShoppingCart.CartIsEmpty and edit away :)

I'm still rubbish at MVC


Thanks a lot. Just what I was looking for!
11 years ago
Hi Guys, just when i needed help on this.

I have a few headers in my website, like featured products, 1 week offers, deadline till offer ends etc.

I have unfortunately hard coded them into the index page or _twocolumns.cshtml.

Now if I need these translated, can i just use this @T("1 week offers")? Sorry this sounds stupid but I cant seem to see how this can work. I tried adding 1 week offers into the resource string in admin>languages, but its not working obviously.

Would u give me some instructions on how to achieve this pls. Thanks in advance.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.