Fork me on GitHub
#shadow-cljs
<
2018-02-17
>
Geoffrey Gaillard15:02:04

Hello ! Did some of you encountered an error while :import-ing goog classes with v2.1.16? I got this error :

The required namespace "goog.i18n.DateTimeSymbols_en" is not available, it was required by "cli/web/services/app/translations.cljs".
The ns looks like :
(ns cli.web.services.app.translations
  (:require [bf.algo.generic :as a]) ;; an internal lib
  (:import [goog.i18n DateTimeSymbols DateTimeSymbols_en]))

hlolli17:02:44

could it be similar as with goog.string format, where you have to both import it and require it?

thheller17:02:07

@ggaillard I think you are supposed to use the :compiler-options {:closure-defines {goog.LOCALE "en"}} and that will pull in the correct symbols

thheller17:02:43

ie. never use the language directy but instead only use goog.i18n.DateTimeSymbols

thheller17:02:11

that being said there is a bug since DateTimeSymbols-en works although its DateTimeSymbols_en

thheller17:02:48

changed it so both versions are now available (just in case). should still rely on goog.LOCALE though

Geoffrey Gaillard22:02:06

@thheller You are 100% right about setting goog.LOCALE to the desired locale instead of importing DateTimeSymbols_* for so many reasons (as cited in the link you provided). But in this case I was trying to build a component that switch date formats explicitly at runtime. So I was kind of poking the thing with a stick, to see what I could get out of it. Thank you for the workaround 🙂