Recent

Author Topic: I hope FreePascal can support syntax like Python's f'string {variable}' or ...  (Read 4081 times)

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12842
  • FPC developer.
Keep in mind also that if the substitutions are not runtime, how will you manage translation ?

One of the reasons format exists is that the strings can be translated.

Fibonacci

  • Hero Member
  • *****
  • Posts: 938
  • Behold, I bring salvation - FPC Unleashed
Keep in mind also that if the substitutions are not runtime, how will you manage translation ?

One of the reasons format exists is that the strings can be translated.

These two concerns live in separate worlds.

Interpolation isn't a replacement for Format in user-facing translatable strings - it's a replacement for Format (and string concatenation) in the vast majority of strings that are never translated: log messages, exceptions, debug output, generated SQL, code generation, assertions, internal tooling, etc. If you want a translatable string, you still write it as a resourcestring and pass it to Format, exactly as today. Interpolation doesn't take that away.

And if anyone is worried about people accidentally interpolating a resourcestring, that's trivially solvable at the compiler level - forbid $'...' on a resourcestring, or warn on it.

Plenty of other languages have both interpolation and i18n side by side. Translation concerns never stopped any of them from adding interpolation - and they shouldn't here either.
FPC Unleashed - inline vars, tuples, statement expressions, array equality, compound assignments, indexed/lazy labels, no-RTTI & more. ⭐ Star it on GitHub!

 

TinyPortal © 2005-2018