amaterasu
I have an umbrella project with N apps, all with the same web structure, but different db and possibly language.
Since the templates are all the same, I thought of creating a common app and I’m using templates like this:
defmodule WebEnglish.CategoryHTML do
use WebEnglish, :html
embed_templates "category_html/*", root: Common.Templates.root()
end
...
defmodule WebSpanish.CategoryHTML do
use WebSpanish, :html
embed_templates "category_html/*", root: Common.Templates.root()
end
I’m now having two issues:
- I can’t use verified routes from
commonmodules that are not templates, sincesigil_pis not available there. - I can use verified routes in templates within
common, but what if I need routes in another language/format? ex.~p"/categories"works, but inWebSpanishthis should be~p"/categorias".
I’m looking at localized routes, but this wouldn’t work either because my understanding is that both categories and categorias would be valid routes in both my web apps.
So I kind of need Router Helpers again, but I know it’s deprecated and I’m looking for an alternative.
What do you think? Thanks!
Trending in Questions
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
Hey guys,
I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly
Do you guys have any suggestions what is the best prac...
New
Kia ora,
We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
Hello,
I’m developing a online persistent chat system (what’s app) like using elixir/dynamodb/aws for a mobile app(flutter).
The diffic...
New
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
Other Trending Topics
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
There are three potential reasons for members of this forum to have a look at https://vutuv.de
You are tired or annoyed of LinkedIn.
Yo...
New
ICal is a library for interacting with iCalendar data. It parses iCalendars into typed Elixir structs via ICal.from_ics, and can prepare ...
New
Latest Phoenix Threads
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #ai
- #phoenix_html
- #elixirconf-us
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
sodapopcan
You can just import them assuming it all uses the same router. Recent Phoenix generators even give you a function to do so:
Take a look in your
lib/my_app_web.exfile to see what that does (look fordef verified_routes).I have no experience localizing Elixir apps yet but there is this project which is by @kip so it’s gotta be good
amaterasu
I can’t do that because
MyAppWebinsideCommonchanges (it’s eitherWebEnglishorWebSpanish).sodapopcan
Ah right. Router helpers would have the same problem, though. Do you separate routers for each language are only one? If you have two then I’m not sure what the answer is here. If you have one then you can still use verified routes.
amaterasu
Router helpers work, I can do this in the
WebEnglish.routerfunction (same for spanish):And in my templates (which are in the
Commonapp):To answer your question: yes, routers are separate per app (since the url structure and/or the languages are different).
sodapopcan
Oh interesting, so the
WebEnglishrouter helpers also work with the Spanish routes?amaterasu
No, no, I have to duplicate that snippet in
WebSpanish, too.sodapopcan
Can you give an example of how you are hoping a shared template will look? Your whole second question of “what if I need routes in another language” is I guess where I’m also confused.
I think you may want to look how the project I linked does it because I don’t think having one web module per language is the best course of action, even if you are only ever going to have two of them. If you do want to have two, I can’t really think of a better way than creating macros that check which module they are in and return the appropriate routes. This would be a 1-1 macro to routes, though which means basically you’d essentially have a third place to manage routes. Maybe someone else will have a better idea. If I think of anything else I’ll report back!
amaterasu
I’d like my template to look like this:
So, basically, I’d like the helper back
As stated before, this works and I know I can use it now, but it’s deprecated and I was wondering if there was an alternative.
Sorry about the misunderstanding with languages: my project has a single template for many frontends. They don’t necessarily have different languages, but they’re deployed separately and have their own db. The only thing in common are templates. Routes may or may not be different for the same entities, that’s why I need separate routers.
BartOtten
After reading the thread I am not sure I understand but let’s kick the can…
I think you don’t necessarily want helpers back but want to be able to write a path in your templates which translates during runtime to an URL depending on certain criteria.
Have a look at GitHub - BartOtten/routex: Build powerful Phoenix routes: localize, customize, and innovate · GitHub. Unlike native verified routes, Routex Verified Routes does support branching. As Routex is extension based, I am quite sure there is a combination of extension which will support your use case.
Demonstration
of
single path in templatewithvariable path during runtimesource code
demo page
amaterasu
Thank you, this looks really promising!