Commit 5c969554 by Eric Fischer

Make messages available in DOM

parent 45a5e785
......@@ -58,6 +58,7 @@
% if waffle_flag_enabled:
<div id="root"></div>
<%static:webpack entry="AssetsPage"></%static:webpack>
<%static:ericfischer locale="fr"></%static:ericfischer>
% else:
<div class="wrapper-assets"></div>
% endif
......
......@@ -86,6 +86,31 @@ engine = Engine(dirs=settings.DEFAULT_TEMPLATE_ENGINE['DIRS'])
source, template_path = Loader(engine).load_template_source(path)
%>${source | n, decode.utf8}</%def>
<%def name="ericfischer(locale)">
<%
from django.conf import settings
from django.template import Template, Context
from webpack_loader.exceptions import WebpackLoaderBadStatsError
path = "{base}/bundles/studio-frontend/locale_messages/{locale}.json".format(
base=settings.STATIC_ROOT,
locale=locale
)
messages = ""
with open(path) as input:
messages = input.read()
return Template("""
<div id=studio-frontend-messages style="display: none;">
{{ messages }}
</div>
""").render(Context({
'messages': messages,
}))
%>
</%def>
<%def name="webpack(entry)">
<%doc>
Loads Javascript onto your page from a Webpack-generated bundle.
......
......@@ -126,6 +126,17 @@ var wpconfig = {
use: 'babel-loader'
},
{
test: /\.json$/,
include: /studio-frontend\/i18n\/locales/,
use: {
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'studio-frontend/locale_messages/'
}
}
},
{
test: /(.scss|.css)$/,
include: [
/studio-frontend/,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment