@@ -5,6 +5,7 @@ module Shared.Api.Locales exposing
55 , exportLocaleUrl
66 , getLocale
77 , getLocales
8+ , getLocalesSuggestions
89 , importLocale
910 , pullLocale
1011 , setDefaultLocale
@@ -13,10 +14,12 @@ module Shared.Api.Locales exposing
1314
1415import File exposing (File )
1516import Http
17+ import Json.Decode as D
1618import Shared.AbstractAppState exposing (AbstractAppState )
17- import Shared.Api exposing (ToMsg , jwtDelete , jwtGet , jwtPostEmpty , jwtPostFile , jwtPostFileWithData , jwtPut )
19+ import Shared.Api exposing (ToMsg , jwtDelete , jwtGet , jwtPostEmpty , jwtPostFile , jwtPostMultiPart , jwtPut )
1820import Shared.Data.Locale as Locale exposing (Locale )
1921import Shared.Data.LocaleDetail as LocaleDetail exposing (LocaleDetail )
22+ import Shared.Data.LocaleSuggestion as LocaleSuggestion exposing (LocaleSuggestion )
2023import Shared.Data.Pagination as Pagination exposing (Pagination )
2124import Shared.Data.PaginationQueryFilters exposing (PaginationQueryFilters )
2225import Shared.Data.PaginationQueryString as PaginationQueryString exposing (PaginationQueryString )
@@ -34,6 +37,16 @@ getLocales _ qs =
3437 jwtGet url ( Pagination . decoder " locales" Locale . decoder)
3538
3639
40+ getLocalesSuggestions : AbstractAppState a -> ToMsg (List LocaleSuggestion ) msg -> Cmd msg
41+ getLocalesSuggestions =
42+ let
43+ decoder =
44+ D . map . items <|
45+ Pagination . decoder " locales" LocaleSuggestion . decoder
46+ in
47+ jwtGet " /locales/suggestions" decoder
48+
49+
3750getLocale : String -> AbstractAppState a -> ToMsg LocaleDetail msg -> Cmd msg
3851getLocale localeId =
3952 jwtGet ( " /locales/" ++ localeId) LocaleDetail . decoder
@@ -57,13 +70,15 @@ setEnabled locale enabled =
5770 jwtPut ( " /locales/" ++ locale. id) withDefault
5871
5972
60- createFromPO : List ( String , String ) -> File -> AbstractAppState a -> ToMsg () msg -> Cmd msg
61- createFromPO params =
73+ createFromPO : List ( String , String ) -> File -> File -> AbstractAppState a -> ToMsg () msg -> Cmd msg
74+ createFromPO params wizardContent mailContent =
6275 let
6376 httpParams =
64- List . map ( \ ( k, v ) -> Http . stringPart k v) params
77+ Http . filePart " wizardContent" wizardContent
78+ :: Http . filePart " mailContent" mailContent
79+ :: List . map ( \ ( k, v ) -> Http . stringPart k v) params
6580 in
66- jwtPostFileWithData " /locales" httpParams
81+ jwtPostMultiPart " /locales" httpParams
6782
6883
6984deleteLocale : String -> String -> AbstractAppState a -> ToMsg () msg -> Cmd msg
0 commit comments