Skip to content

Commit

Permalink
Setup test page
Browse files Browse the repository at this point in the history
  • Loading branch information
virolea committed Sep 3, 2024
1 parent 205180a commit 68bdb8c
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 3 deletions.
11 changes: 11 additions & 0 deletions test/dummy/app/controllers/pages_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class PagesController < ApplicationController
before_action :set_locale

private

def set_locale
if params[:locale]
Rosetta.locale = params[:locale]
end
end
end
11 changes: 8 additions & 3 deletions test/dummy/app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html>
<html class="h-full">
<head>
<title><%= content_for(:title) || "Dummy" %></title>
<meta name="viewport" content="width=device-width,initial-scale=1">
Expand All @@ -14,9 +14,14 @@
<link rel="icon" href="/icon.svg" type="image/svg+xml">
<link rel="apple-touch-icon" href="/icon.png">
<%= stylesheet_link_tag "application" %>
<script src="https://cdn.tailwindcss.com"></script>
</head>

<body>
<%= yield %>
<body class="h-full" data-controller="dialog">
<div class="min-h-full">
<main class="mx-auto max-w-4xl px-4 sm:px-6 lg:px-8 py-10">
<%= yield %>
</main>
</div>
</body>
</html>
19 changes: 19 additions & 0 deletions test/dummy/app/views/pages/home.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<h1 class="text-2xl font-semibold">Test Page</h1>

<div class="space-y-4 mt-8">
<div>
<h3 class="text-lg font-semibold">Current locale</h3>
<div>
<%= Rosetta.locale.name %>
</div>
</div>

<div>
<h3 class="text-lg font-semibold">Available locales</h3>
<ul class="list-disc pl-4">
<% Rosetta::Locale.available_locales.each do |locale| %>
<li><%= locale.name %> - <%= link_to "Switch", root_path(locale: locale.code), class: "text-blue-500 hover:underline" %></li>
<% end %>
</ul>
</div>
</div>
2 changes: 2 additions & 0 deletions test/dummy/config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Rails.application.routes.draw do
mount Rosetta::Engine => "/rosetta"

root to: "pages#home"
end

0 comments on commit 68bdb8c

Please sign in to comment.