This repository was archived by the owner on Mar 11, 2025. It is now read-only.
Basic skeleton for a multilinual actix-askama site#599
Closed
gpmake wants to merge 1 commit into
Closed
Conversation
Member
|
Please have a look at #600 if that kind of localization would work for you. It has the added feature that you don't need to copy the structure multiple times, which I guess works better if you want to support a lot of languages. |
Collaborator
|
So I don't think we actually want an example of this, but here's the pattern I was trying to explain: #[derive(Template)]
#[template(path = "home/home-en.html")]
struct HomeEn<'a>(Home<'a>);
impl<'a> std::ops::Deref for HomeEn<'a> {
type Target = Home<'a>;
fn deref(&self) -> &Self::Target {
&self.0
}
}
struct Home<'a> {
lang: &'a str,
title: &'a str,
page: &'a str,
}This way you can have multiple templates defined that all use the same underlying context type. You could potentially also have an |
Collaborator
|
Going to close this for now; let's discuss in #600. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I created a basic multi-language site with two pages (Home and About). For each page, I used two template structs with the same content. A possible next step is to create a newtype wrapped around an inner type with a Deref impl to share the same type definitions for the template structs. Here is the repository create on my GitHub account: git@github.com:gpmake/basic-actix-askama-multilingual-site.git