-1

I'm using GNU gettext to translate asp.net web-page. For extract the string i'm using PoEdit.

In Javascript code, I convert the normal labelString 'Hour'

scaleLabel: {
 display: true,
 labelString: 'Hour',
},

to

scaleLabel: {
 display: true,
 labelString: '@Strings.T("Hour")',
},

But PoEdit can't extract this string. Is there a way to translate this type of string?

Hyyan Abo Fakher
  • 3,497
  • 3
  • 21
  • 35
stukdev
  • 198
  • 1
  • 4
  • 16

1 Answers1

0

GNU gettext and Poedit support JavaScript — in JavaScript files. Your out of context code snippet doesn't make it clear how and where you have it, or how you extract it.

However, this code doesn't contain any translatable string, any calls to gettext functions, so xgettext cannot possibly extract anything from it. The entire '@Strings.T("Hour")' bit is a literal — string that isn't interpreted in any way and can't very well be parsed (how would you distinguish between somebody meaning to print that out and an actual function call?). You have to call a translation function to get a translation at runtime — and for xgettext to be able to find that call.

See the documentation for the gettext library you use. It explains usage.

Václav Slavík
  • 6,445
  • 2
  • 28
  • 25
  • The file is Javascript, the @Strings.T is a c# function that use xgettext to search for translations. The code works well, the real problem is the extractor, with '@Strings.T("Hour")' Poedit can't extract "Hour" becouse think it's a literal string. So i don't understand how can i force PoEdit to do this. At the moment i try write a custom batch file that try to extract the text '@Strings.T. – stukdev Sep 06 '18 at 08:56
  • So you say the file is JavaScript and it's a C# function — well, pick one. You can "force" Poedit (notice the spelling) to do what you want by clarifying to yourself what language you write the code in, putting it in a file that can be recognized (via extension) as said file, and writing code that *actually calls a function* in said language. Whatever it is that you use for gettext, it has documentation. *Read it.* You do need to understand basic concepts behind gettext, e.g. its use of function calls, to be able to write working code using it. – Václav Slavík Sep 07 '18 at 07:20