On Friday, 27 July 2012 at 00:19:37 UTC, José Armando García Sancio wrote:
On Thu, Jul 26, 2012 at 4:59 PM, Brian Schott <briancsch...@gmail.com> wrote:
On Thursday, 26 July 2012 at 23:51:34 UTC, José Armando García Sancio wrote:

On Thu, Jul 26, 2012 at 3:34 PM, dnewbie <r...@myopera.com> wrote:

There is --ctags output in Dscanner
https://github.com/Hackerpilot/Dscanner


Very interesting. Is this Dscanner pluggable? I would be interesting to use Dscanner for localization. For example it would be nice if it could generate a list of all the strings that are passed to a specific
function.

This is how people generate localizable string to use for gettext.

Thoughts?
-Jose


Dscanner has a tokenizer for D code, so it would not be hard to make a
program that uses the tokenizer to swap out string literals.


Swap out? Not sure what you mean by this. I don't want to localize the code. I just want to enumerate them all so that a localization team
can provide a catalog that could be use to do the translation at
runtime.

In C/C++ a lot of teams do localization by providing a #define "_" that simply returns the string passed into it. In D this would be a
template that could be compiled out.

The cool thing about having this "_" macro is that then you can have a tool that can extract all occurrences of such a macro. Gettext has
such a tool for C/C++.

If we want to leverage gettext in D then we would have to build the equivalent of that tool for D. I was wondering if Dscanner can be
extended to do this.

Thanks,
-Jose

Something like this:

writeln(tokenize(sourceCode).filter!("a.type > TokenType.STRINGS_BEGIN && a.type < TokenType.STRINGS_END")().map!("a.value")().joiner("\n"));

I'm booted into Windows at the moment so I haven't tested that, but it should work if you just want a dump of all the strings. The line-of-code feature works in a similar way.

Reply via email to