lingo.dev icon indicating copy to clipboard operation
lingo.dev copied to clipboard

SDK Modules (/packages/sdk): Implement convenience methods for common use cases

Open 7hacker opened this issue 8 months ago • 1 comments

The SDK could benefit from some convenience methods that encapsulate common usage patterns, such as:

// Localize a simple key-value map
async localizeSimpleMap(
 map: Record<string, string>,
 params: Z.infer<typeof localizationParamsSchema>
): Promise<Record<string, string>> {
 return this.localizeObject(map, params);
}
// Localize an array of strings
async localizeStringArray(
 strings: string[],
 params: Z.infer<typeof localizationParamsSchema>
): Promise<string[]> {
 const mapped = strings.reduce((acc, str, i) => {
   acc[`item_${i}`] = str;
   return acc;
 }, {} as Record<string, string>);
  const result = await this.localizeObject(mapped, params);
  return Object.values(result);
}

7hacker avatar Mar 25 '25 03:03 7hacker

nice, this one is quick and easy!

(must have tests as well btw)

maxprilutskiy avatar May 21 '25 19:05 maxprilutskiy

@maxprilutskiy can you please assign this to me?

apsinghdev avatar Jun 21 '25 07:06 apsinghdev

Sure @apsinghdev, thank you for your interest. And dont forget the test coverage, please ;)

mathio avatar Jun 23 '25 07:06 mathio