From f5e0e9fec543f98adaba9d5c04c53950ea2ca152 Mon Sep 17 00:00:00 2001 From: makkarpov Date: Thu, 14 Apr 2016 21:30:14 +0300 Subject: [PATCH] Add type alias `LString` to `LValue[String]` --- .../src/main/scala/ru/makkarpov/scalingua/I18n.scala | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scalingua/src/main/scala/ru/makkarpov/scalingua/I18n.scala b/scalingua/src/main/scala/ru/makkarpov/scalingua/I18n.scala index f222eb4..d518ca1 100644 --- a/scalingua/src/main/scala/ru/makkarpov/scalingua/I18n.scala +++ b/scalingua/src/main/scala/ru/makkarpov/scalingua/I18n.scala @@ -19,24 +19,26 @@ package ru.makkarpov.scalingua import scala.language.experimental.macros object I18n { + type LString = LValue[String] + implicit class StringInterpolator(val sc: StringContext) extends AnyVal { def t(args: Any*)(implicit lang: Language, outputFormat: OutputFormat[String]): String = macro Macros.interpolate[String] - def lt(args: Any*)(implicit outputFormat: OutputFormat[String]): LValue[String] = + def lt(args: Any*)(implicit outputFormat: OutputFormat[String]): LString = macro Macros.lazyInterpolate[String] } def t(msg: String, args: (String, Any)*)(implicit lang: Language, outputFormat: OutputFormat[String]): String = macro Macros.singular[String] - def lt(msg: String, args: (String, Any)*)(implicit outputFormat: OutputFormat[String]): LValue[String] = + def lt(msg: String, args: (String, Any)*)(implicit outputFormat: OutputFormat[String]): LString = macro Macros.lazySingular[String] def tc(ctx: String, msg: String, args: (String, Any)*)(implicit lang: Language, outputFormat: OutputFormat[String]): String = macro Macros.singularCtx[String] - def ltc(ctx: String, msg: String, args: (String, Any)*)(implicit outputFormat: OutputFormat[String]): LValue[String] = + def ltc(ctx: String, msg: String, args: (String, Any)*)(implicit outputFormat: OutputFormat[String]): LString = macro Macros.lazySingularCtx[String] def p(msg: String, msgPlural: String, n: Long, args: (String, Any)*) @@ -44,7 +46,7 @@ object I18n { macro Macros.plural[String] def lp(msg: String, msgPlural: String, n: Long, args: (String, Any)*) - (implicit outputFormat: OutputFormat[String]): LValue[String] = + (implicit outputFormat: OutputFormat[String]): LString = macro Macros.lazyPlural[String] def pc(ctx: String, msg: String, msgPlural: String, n: Long, args: (String, Any)*) @@ -52,6 +54,6 @@ object I18n { macro Macros.pluralCtx[String] def lpc(ctx: String, msg: String, msgPlural: String, n: Long, args: (String, Any)*) - (implicit outputFormat: OutputFormat[String]): LValue[String] = + (implicit outputFormat: OutputFormat[String]): LString = macro Macros.lazyPluralCtx[String] }