如何使用Spring Boot + Thymeleaf配置国际化?(How do I configure internationalization with Spring Boot + Thymeleaf?)

在使用Thymeleaf作为模板渲染器的Spring Boot项目中,如何根据用户区域设置将一段文本翻译成多种语言?

我如何在Thymeleaf中显示这些消息?


In a Spring Boot project using Thymeleaf as the template renderer, how would one go on about having a piece of text be translated into multiple languages, depending on user locale?

How do I display these messages in Thymeleaf?


原文:https://stackoverflow.com/questions/50421043
2022-04-06 12:04

相关问答

更多

在Angular.js中显示多个计时器功能(Showing multiple timer function in Angular.js)

你基本上是在启动多个startTimer函数,所以它正在加起来。 如果我理解你的问题,你甚至不需要拥有所有那些观察者和超时。 你可以用这种方式使用$ interval: $scope.Timer = $interval(function () { ++$scope.tickCount if ($scope.tickCount <= 5) { $scope.timer1++ } else { $scope.timer2++ if ($scope.tickCou...

如何在tkinter倒数计时器上实现启动,停止和重置功能?(How do I implement start, stop and reset features on a tkinter countdown timer?)

当你点击三个按钮时,你的问题仍然有点模糊,所以我不得不猜测。 为了支持这些功能,需要添加更多的实例属性来跟踪应用程序的状态,即self._paused和self._starttime 。 这些可以根据需要用各种方法检查和更新。 from tkinter import * class Application(Frame): def __init__(self,master): super(Application,self).__init__(master) ...

角度js计时器功能不在停止按钮上工作(angular js timer function not working on stop button)

stoptimer函数中if语句中的条件缺少否定: if(angular.isUndefined(timer)){ 应该 if(!angular.isUndefined(timer)){ The condition in your if statement in the stoptimer function is missing a negation : if(angular.isUndefined(timer)){ should be if(!angular.isUndefined(tim...

为什么我的计时器在关闭申请后重置?(Why my timer be reset after closing application?)

没有完美的方法来阻止您的服务被停止。 START_STICKY并不意味着Android不会终止服务。 如果资源紧张,Android可能仍然会终止服务,STICKY只会帮助操作系统在资源紧缩消失后重启服务。 因此,基本问题是你假设服务永远不会被杀死,你的时间依赖于此。 最好将最后播放的时间存储在首选项或SQLlite中(或将其置于onSaveInstance状态的bundle中),并在每次进入onStartCommand时从那里读取它。 当然,您需要处理用户时间更改,堆栈溢出上有许多线程,您可以参考...

课程倒数计时器不会重置(Class countdown timer doesn't reset)

你应该改变你的Reset方法: public void Reset() { millisInFuture = pls; x=0; Initialize(); } You should change your Reset method: public void Reset() { millisInFuture = pls; x=0; Initialize(); }

Angular 2可重新启动计时器(Angular 2 reSTARTable timer)

您可以通过使用switchMap()来实现重新启动计时器: const timerControl$ = new Subject<any>(); const timer$ = timerControl$.switchMap(() => Observable.timer(0, 1000)); timer$.subscribe(i => console.log(i)); // start timer timerControl$.next(); // re-start timer timerCont...

androidL如何重置计时器(androidL how to reset a timer)

在代码中挖掘更多细节并通过网络进一步研究,我找到了答案并修改了如下代码并且它有效。 总而言之,感谢Monica推出计时码表,看起来不错! 并感谢Zyoo让我在ACTION_DOWN下制作一个removeCallbacks if(event.getAction()==MotionEvent.ACTION_DOWN ) { if(startTime == 0L) { ...

如何从控制器启动和重置角度计时器?(How to start and reset angular timer from controller?)

从这里查看示例: https : //siddii.github.io/angular-timer/examples.html#/angularjs-single-timer-source Check out examples from here : https://siddii.github.io/angular-timer/examples.html#/angularjs-single-timer-source

添加计时器的启动,停止和重置按钮(Adding start, stop, and reset buttons for a timer)

(function() { "use strict"; var secondsLabel = document.getElementById('seconds'), minutesLabel = document.getElementById('minutes'), hoursLabel = document .getElementById('hours'), totalSeconds = 0, startButton = document.getElementById('st...

如何重置和设置定时器功能?(How to reset and set up timer function?)

问题来自范围冲突。 在你的代码中 // responseTimer is declared as a global function var responseTimer = function (time) { // as the var keyword is not specify, scope of responseTimer becomes global and not local and overrides the previous declaration responseTi...

相关文章

更多

什么是Spring boot

什么是Spring boot? Spring Boot是由Pivotal团队提供的全新框架,其设计目的 ...

快速了解Spring Boot

Spring Boot会根据使用@EnableAutoConfiguration批注添加到项目中的依赖 ...

Spring Boot上传文件示例

org.springframework.boot&lt

Spring boot入门实例

入门实例是基于maven工程,主要配置: spring boot 父节点依赖,引入这个之后相关的引入就 ...

Spring boot整合mybatis plus

快速了解mybatis plus 是对Mybatis框架的二次封装和扩展 纯正血统:完全继承原生 My ...

Spring Boot使用FastJson解析JSON数据

Spring Boot默认使用jackson,国内很多人比较习惯用fastjson。所以我们看一下怎么 ...

Spring Boot war包启动

​Spring Boot war包启动,实现SpringBootServletInitializer启 ...

最新问答

更多

您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)

将diff文件复制到存储库的根目录,然后执行以下操作: git apply yourcoworkers.diff 有关apply命令的更多信息, apply 见其手册页 。 顺便说一下:一个更好的方法是通过文件交换整个提交文件是发送者上的命令git format-patch ,然后在接收器上加上git am ,因为它也传送作者信息和提交信息。 如果修补程序应用程序失败,并且生成diff的提交实际上在您的备份中,则可以使用尝试在更改中合并的apply程序的-3选项。 它还适用于Unix管道,如下

将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)

尝试将第二行更改为snprintf(buf1, sizeof buf1, "%.2f", balance1); 。 另外,为什么要声明用该特定表达式分配缓冲区的存储量? EDIT @LưuVĩnhPhúc在下面的评论中提到我的原始答案中的格式说明符将舍入而不是截断,因此根据如何在不使用C舍入的情况下截断小数,您可以执行以下操作: float balance = 200.56866; int tmp = balance1 * 100; float balance1 = tmp / 100.0; c

OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)

这是简单的解决方案 在你需要写的控制器中 BackendMenu::setContext('Archetypics.Team', 'website', 'team'); 请参阅https://octobercms.com/docs/backend/controllers-views-ajax#navigation-context BackendMenu::setContext('Author.Plugin name', 'Menu code', 'Sub menu code'); 你需要在r

页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)

每当发出请求时ASP都会创建一个新的Page对象,并且一旦它将响应发送回用户就不会保留对该Page对象的引用,因此只要你找不到某种方法来保持生命自己引用该Page对象后,一旦发送响应, Page和只能通过该页面访问的所有对象才有资格进行垃圾回收。 ASP creates a new Page object whenever a request is made, and it does not hold onto the reference to that Page object once it

codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)

要在生产服务器中调试这个,你可以临时放 error_reporting(E_ALL); 并查看有哪些其他错误阻止正确的重定向。 您还应该检查生产服务器发送的响应标头。 它是否具有“缓存”,是否需要重新验证标头等 to debug this in production server, you can temporary put error_reporting(E_ALL); and see what other errors are there that prevents the proper

在计算机拍照在哪里进入

打开娥的电脑.在下面找到视频设备点击进去就可以了...

使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)

你是对的。 第一次输入后,换行符将保留在输入缓冲区中。 第一次读取后尝试插入: cin.ignore(); // to ignore the newline character 或者更好的是: //discards all input in the standard input stream up to and including the first newline. cin.ignore(numeric_limits::max(), '\n'); 您必须为#inc

No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)

for (int k = 0; k > 10; k++) { System.out.println(k); } k不大于10,所以循环将永远不会执行。 我想要什么是k<10 ,不是吗? for (int k = 0; k < 10; k++) { System.out.println(k); } for (int k = 0; k > 10; k++) { System.out.println(k); } k is not greater than 10, so loop

单页应用程序:页面重新加载(Single Page Application: page reload)

优点是不注销会避免惹恼用户,以至于他们会想要杀死你:-)。 说真的,如果每次刷新页面时应用程序都会将我注销(或者在新选项卡中打开一个链接),我再也不会使用该应用程序了。 好吧,不要这样做。 确保身份验证令牌存储在刷新后的某个位置,即不在某些JS变量中,而是存储在cookie或本地存储中。 The advantage is that not logging off will avoid pissing off your users so much that they'll want to kill

在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)

EXECUTE IMMEDIATE 'SELECT '||field_val_temp ||' FROM tableb WHERE function_id = :func_val AND rec_key = :rec_key' INTO field_val USING 'STDCUSAC' , yu.rec_key; 和, EXECUTE IMMEDIATE 'UPDATE tablec SET field_val_'||i||' = :field_val' USI