ResilientLang docsDeveloper documentation (draft, product name is a placeholder)

Go SDK

Module github.com/lawleys/language/sdks/go (a placeholder path: verify when the repository and product name are final), Go 1.21+, standard library only, every call takes a context.Context. Not published; no default API URL. See the SDK overview.

import rl "github.com/lawleys/language/sdks/go"

ctx := context.Background()
c, err := rl.NewClient("https://api.example.com", os.Getenv("RL_API_KEY"))   // base URL: no default

site, err := c.Sites.Create(ctx, rl.CreateSiteRequest{Name: "My shop", SourceLanguage: "en", TargetLanguages: []string{"fr", "de"}, AllowedOrigins: []string{"https://shop.example"}})
keys, err := c.Strings.SubmitAll(ctx, site.ID, []rl.StringItem{{Text: "Add to basket"}, {Text: "Checkout", Context: "button"}}, 0, nil)

jobs, err := c.Translate(ctx, site.ID, rl.TranslateRequest{Langs: []string{"fr", "de"}})   // one job per language
for _, j := range jobs.Jobs {
    done, err := c.Jobs.Wait(ctx, j.ID, rl.WaitOptions{Timeout: 10 * time.Minute})
}
pub, err := c.Publish(ctx, site.ID, rl.PublishRequest{})
done, err := c.Jobs.Wait(ctx, pub.ID, rl.WaitOptions{})                                 // done.State: succeeded | failed | canceled

all, err := c.Translations.ListAll(ctx, site.ID, "fr", "")                               // follows nextCursor
exp, err := c.Export(ctx, site.ID, "xliff2", "fr", "de")                                  // exp.Data, exp.ContentType, exp.Filename
res, err := c.ImportFile(ctx, site.ID, rl.ImportFileOptions{Content: data, Filename: "fr.po", Lang: "fr", DryRun: true})
q, err := c.Quota(ctx)                                                                    // *APIError 404 not-found when quotas are off

(Error handling of each err is omitted for brevity.) Cancelling the context stops the call and any retry sleep immediately.

Options#

NewClient(url, key, rl.WithHTTPClient(hc), rl.WithTimeout(30*time.Second), rl.WithMaxRetries(2), rl.WithMaxRetryDelay(10*time.Second), rl.WithAllowInsecureHTTP(), rl.WithUserAgent(...)). Your http.Client is copied and its CheckRedirect replaced, so redirects are never followed. Writes accept an optional rl.RequestOptions{IdempotencyKey: "..."}. KeyWithSecret.Secret prints as rl_sec_***; call Secret.Reveal() once to store it.

Where next#

Error handling, verify webhooks (ConstructWebhookEvent) and verify a published bundle (ParseVerifiedManifest).