Documentation ¶
Index ¶
- Variables
- func HandleEvent(ctx context.Context, services services, event cloudevents.Event) (err error)
- type Approval
- type Client
- type Config
- type Directory
- type File
- type Language
- type Object
- type Options
- type Pagination
- type Project
- type Result
- type SimpleTranslation
- type String
- type StringTranslation
- type Translation
- type TranslationHandler
- type TranslationSource
Constants ¶
This section is empty.
Variables ¶
var (
// ErrEventNotSupported error for event key not yet supported
ErrEventNotSupported = merry.Sentinel("event not supported")
)
var ErrRequestFailed = merry.Sentinel("Request failed")
ErrRequestFailed error for failed requests
Functions ¶
func HandleEvent ¶
func HandleEvent(ctx context.Context, services services, event cloudevents.Event) (err error)
HandleEvent for events from PubSub (or other CloudEvent source)
Types ¶
type Approval ¶
type Approval struct { ID int `json:"id"` TranslationID int `json:"translationId"` StringID int `json:"stringId"` LanguageID string `json:"languageId"` }
Approval model
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client for crowdin interactions
func (*Client) List ¶
func (c *Client) List(ctx context.Context) ([]Translation, error)
List translations in crowdin
func (*Client) SaveTranslations ¶
func (c *Client) SaveTranslations(objects []TranslationSource) error
SaveTranslations stores updated translations from the objects, if they are changed
type Directory ¶
type Directory struct { ID int `json:"id,omitempty"` Name string `json:"name"` Title string `json:"title,omitempty"` }
Directory model
type File ¶
type File struct { ID int `json:"id"` Name string `json:"name"` Title string `json:"title"` DirectoryID int `json:"directoryId"` }
File model
type Object ¶
type Object[T any] struct { Data T `json:"data"` }
Object is the base of all responses in Crowdin
type Options ¶
type Options struct { Project Project DirectoryID int Translations []Translation }
Options are common options for every translation collection
type Pagination ¶
Pagination contains simple pagination data
type Project ¶
type Project struct { ID int `json:"id"` SourceLanguageId string `json:"sourceLanguageId"` TargetLanguages []Language `json:"targetLanguages"` }
Project model
type Result ¶
type Result[T any] struct { Object[T] Pagination Pagination }
Result extends Object with Pagination data
type SimpleTranslation ¶
type SimpleTranslation struct { ID string ParentID string Values map[string]string Language string Changed bool }
SimpleTranslation contains info about the translation object as stored in the database
type String ¶
type String struct { ID int `json:"id"` FileID int `json:"fileId"` Text string `json:"text"` Identifier string `json:"identifier"` Context string `json:"context"` IsHidden bool `json:"isHidden"` }
String model
type StringTranslation ¶
type StringTranslation struct { StringID int `json:"stringId"` TranslationID int `json:"translationId"` Text string `json:"text"` }
StringTranslation model
type Translation ¶
Translation contains data for a specific translation key
func GetTranslationsFromZip ¶
func GetTranslationsFromZip(zipFile string) ([]Translation, error)
GetTranslationsFromZip retrieves translations from a zip containing csv files
type TranslationHandler ¶
type TranslationHandler[T any, TUpdate any] struct { Collection string Fetch func(ctx context.Context, language string) ([]T, error) ConvertToUpdate func(item SimpleTranslation) TUpdate Save func(ctx context.Context, item TUpdate) error GetContext func(identifier string) string }
TranslationHandler handles translations
func NewTranslationHandler ¶
func NewTranslationHandler[T any, TUpdate any]( collection string, fetch func(ctx context.Context, language string) ([]T, error), convertToUpdate func(item SimpleTranslation) TUpdate, save func(ctx context.Context, item TUpdate) error, getContext func(identifier string) string) TranslationHandler[T, TUpdate]
NewTranslationHandler creates a handler from functions
type TranslationSource ¶
type TranslationSource interface { GetCollection() string GetItemID() int GetLanguage() string // GetValues returns a field mapped dictionary with the translation source as value, identifier as key GetValues() map[string]string }
TranslationSource is an object which contains fields that can be translated