Create Templatetag for change language whit the current path

This commit is contained in:
Henry Bravo 2017-06-13 22:35:15 -05:00
commit 8acd249b4d
10 changed files with 356 additions and 42 deletions

View file

@ -1,3 +1,5 @@
1.0.13: 2017-06-13
* [datacenterlight] Added translations for email and name placeholders fields
1.0.12: 2017-06-13
* [datacenterlight] Added from address for EmailMessage that was missing
1.0.11: 2017-06-12

View file

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-06-09 16:08-0500\n"
"POT-Creation-Date: 2017-06-13 13:41-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -136,7 +136,8 @@ msgid "I want it!"
msgstr "Das will ich haben!"
#: templates/datacenterlight/home.html:46
#: templates/datacenterlight/includes/_footer.html:14
#: templates/datacenterlight/includes/_footer.html:11
#: templates/datacenterlight/includes/_footer.html:31
#: templates/datacenterlight/includes/_navbar.html:26
msgid "What is it"
msgstr "Was ist es?"
@ -153,7 +154,7 @@ msgstr ""
"errichten."
#: templates/datacenterlight/home.html:61
msgid "Only wants you to pay for what you actually need.\\u2028"
msgid "Only wants you to pay for what you actually need."
msgstr ""
"Möchte, dass du nur bezahlst, was du auch wirklich brauchst: Wähle deine "
"Ressourcen individuell aus!"
@ -161,7 +162,7 @@ msgstr ""
#: templates/datacenterlight/home.html:65
msgid ""
"Is creative, using a modern and alternative design for a data center in "
"order to make it more sustainable and affordable at the same time.\\u2028"
"order to make it more sustainable and affordable at the same time."
msgstr ""
"Ist kreativ, indem es sich ein modernes und alternatives Layout zu Nutze "
"macht um Nachhaltigkeit zu fördern und somit erschwingliche Preise bieten zu "
@ -177,7 +178,8 @@ msgstr ""
"Lizenzgebühren verzichten können."
#: templates/datacenterlight/home.html:89
#: templates/datacenterlight/includes/_footer.html:17
#: templates/datacenterlight/includes/_footer.html:14
#: templates/datacenterlight/includes/_footer.html:34
#: templates/datacenterlight/includes/_navbar.html:29
msgid "Scale out"
msgstr "Skalierung"
@ -193,7 +195,8 @@ msgstr ""
"komponenten hinzugekauft und skalieren so das Datencenter."
#: templates/datacenterlight/home.html:115
#: templates/datacenterlight/includes/_footer.html:20
#: templates/datacenterlight/includes/_footer.html:17
#: templates/datacenterlight/includes/_footer.html:37
#: templates/datacenterlight/includes/_navbar.html:32
msgid "Reliable and light"
msgstr "Zuverlässig und leicht"
@ -240,9 +243,25 @@ msgstr "Standort des Datacenters ist in der Schweiz"
msgid "10 GB Storage (SSD)"
msgstr "10 GB Storage (SSD)"
#: templates/datacenterlight/home.html:163
#: templates/datacenterlight/order.html:74
#: templates/datacenterlight/pricing.html:76
#: templates/datacenterlight/index.html:289
msgid "Name"
msgstr ""
#: templates/datacenterlight/index.html:290
msgid "Your Name"
msgstr "Dein Name"
#: templates/datacenterlight/index.html:293
msgid "Email"
msgstr "E-Mail-Adresse"
#: templates/datacenterlight/index.html:294
msgid "Your Email"
msgstr "Deine E-Mail"
#: templates/datacenterlight/index.html:297
#: templates/datacenterlight/order.html:133
#: templates/datacenterlight/pricing.html:161
msgid "Order Now!"
msgstr "Bestelle jetzt!"
@ -258,22 +277,24 @@ msgstr "Fragen?"
msgid "Contact us!"
msgstr "Kontaktiere uns!"
#: templates/datacenterlight/includes/_footer.html:10
msgid "Home"
msgstr "Home"
#: templates/datacenterlight/includes/_footer.html:20
#: templates/datacenterlight/includes/_navbar.html:35
msgid "Order VM"
msgstr "VM bestellen"
#: templates/datacenterlight/includes/_footer.html:23
msgid "Pricing"
msgstr "Preise"
#: templates/datacenterlight/includes/_footer.html:27
#: templates/datacenterlight/includes/_footer.html:44
#: templates/datacenterlight/includes/_navbar.html:38
msgid "Contact"
msgstr "Kontakt"
#: templates/datacenterlight/includes/_navbar.html:35
msgid "Order VM"
msgstr "VM bestellen"
#: templates/datacenterlight/includes/_footer.html:27
msgid "Home"
msgstr "Home"
#: templates/datacenterlight/includes/_footer.html:40
msgid "Pricing"
msgstr "Preise"
#: templates/datacenterlight/order.html:30
#: templates/datacenterlight/pricing.html:30
@ -400,6 +421,18 @@ msgstr ""
msgid "as soon as possible!"
msgstr ""
#~ msgid "month"
#~ msgstr "Monat"
#~ msgid "Want to know more? Subscribe to our newsletter!"
#~ msgstr "Willst du mehr wissen? Abonniere unseren Newsletter!"
#~ msgid "I want to have it!"
#~ msgstr "Das möchte ich haben!"
#~ msgid "Buy VM"
#~ msgstr "VM Kaufen"
#~ msgid ""
#~ "Reuse existing factory halls intead of building an expensive building."
#~ msgstr ""

View file

@ -58,11 +58,11 @@
</li>
<li>
<i class="fa-li fa fa-check-square-o fa-lg"></i>
<p class="lead">{% trans "Only wants you to pay for what you actually need." %}</p>
<p class="lead">{% trans "Only wants you to pay for what you actually need." %}</p>
</li>
<li>
<i class="fa-li fa fa-check-square-o fa-lg"></i>
<p class="lead">{% trans "Is creative, using a modern and alternative design for a data center in order to make it more sustainable and affordable at the same time." %}</p>
<p class="lead">{% trans "Is creative, using a modern and alternative design for a data center in order to make it more sustainable and affordable at the same time." %}</p>
</li>
<li>
<i class="fa-li fa fa-check-square-o fa-lg"></i>

View file

@ -1,5 +1,6 @@
{% load staticfiles i18n%}
{% get_current_language as LANGUAGE_CODE %}
{% load custom_tags %}
<nav class="navbar navbar-default navbar-fixed-top topnav" role="navigation">
<div class="topnav">
<!-- Brand and toggle get grouped for better mobile display -->
@ -49,29 +50,12 @@
</div>
<div class="drop-language">
{% if LANGUAGE_CODE == 'en-us'%}
{% if request.resolver_match.url_name == "index" %}
<a class="url" href="{{base_url}}/de/datacenterlight" >Deutsch</a>
{% endif %}
{% if request.resolver_match.url_name == "order" %}
<a class="url" href="{{base_url}}/de/datacenterlight/order" >Deutsch</a>
{% endif %}
{% if request.resolver_match.url_name == "pricing" %}
<a class="url" href="{{base_url}}/de/datacenterlight/pricing" >Deutsch</a>
{% endif %}
<a class="url" href="{% change_lang 'de' %}">Deutsch</a>
{% else %}
{% if request.resolver_match.url_name == "index" %}
<a class="url" href="{{base_url}}/en-us/datacenterlight" >English</a>
<a class="url" href="{% change_lang 'en-us' %}" >English</a>
{% endif %}
{% if request.resolver_match.url_name == "order" %}
<a class="url" href="{{base_url}}/en-us/datacenterlight/order" >Deutsch</a>
{% endif %}
{% if request.resolver_match.url_name == "pricing" %}
<a class="url" href="{{base_url}}/en-us/datacenterlight/pricing" >Deutsch</a>
{% endif %}
<a class="url" href="{{base_url}}/en-us/datacenterlight" ></a>
{% endif %}
</div>
</li>
</ul>

View file

@ -0,0 +1,270 @@
{% extends "datacenterlight/base.html" %}
{% load staticfiles i18n%}
{% get_current_language as LANGUAGE_CODE %}
{% block content %}
<!-- Header -->
<div class="intro-header" id="home">
<div class="container">
<div class="row">
<div class="col-lg-12">
<div class="intro-message">
<h1>DataCenterLight</h1>
<h3>{% trans "Finally, an affordable VM hosting in Switzerland!" %}</h3>
<hr class="intro-divider">
<ul class="list-inline intro-social-buttons">
<li>
<a class="btn btn-default btn-lg btn-transparent url" href="javascript:void(0)" data-url="#how" ><i class="#Services"></i> <span class="network-name">{% trans "What is it?" %}</span></a>
</li>
<li>
<a class="btn btn-primary btn-lg page-scroll url" href="javascript:void(0)" data-url="#price" ><span class="network-name">{% trans "I want it!" %}</span></a>
</li>
</ul>
</div>
</div>
</div>
</div>
<div class="triangle-left"></div>
<div class="triangle-right"></div>
<!-- /.container -->
</div>
<!-- /.intro-header -->
<!-- Page Content -->
<div class="split-section right" id="how">
<div class="container">
<div class="row">
<div class="col-xs-12 col-sm-6 col-md-6 icon-section">
<i class="fa fa-cogs" aria-hidden="true"></i>
</div>
<div class="col-xs-12 col-sm-6 col-md-6">
<div class="split-text">
<div class="split-title">
<h2>{% trans "What is it" %}</h2>
</div>
<div class="split-description">
<ul class="fa-ul">
<li>
<i class="fa-li fa fa-check-square-o fa-lg"></i>
<p class="lead">{% trans "Reuses existing factory halls instead of building a new expensive building." %}
</p>
</li>
<li>
<i class="fa-li fa fa-check-square-o fa-lg"></i>
<p class="lead">{% trans "Only wants you to pay for what you actually need." %}</p>
</li>
<li>
<i class="fa-li fa fa-check-square-o fa-lg"></i>
<p class="lead">{% trans "Is creative, using a modern and alternative design for a data center in order to make it more sustainable and affordable at the same time." %}</p>
</li>
<li>
<i class="fa-li fa fa-check-square-o fa-lg"></i>
<p class="lead">{% trans "Cuts down the costs for you by using FOSS (Free Open Source Software) exclusively, wherefore we can save money from paying licenses." %}</p>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<!-- /.container -->
<!-- /.option 1 -->
</div>
<div class="split-section left" id="your">
<div class="container">
<div class="row">
<div class="col-xs-12 col-sm-6 col-md-6">
<div class="split-text">
<div class="split-title">
<h2>{% trans "Scale out" %}</h2>
</div>
<div class="split-description">
<p class="lead">{% trans "We don't use special hardware. We use commodity hardware: we buy computers that you buy. Just many more and put them in a cozy home for computers called data center." %}</p>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-6 col-md-6 icon-section">
<i class="fa fa-rocket" aria-hidden="true"></i>
</div>
</div>
</div>
<!-- /.container -->
<!-- /.option 1 -->
</div>
<div class="split-section right" id="our">
<div class="container">
<div class="row">
<div class="col-xs-12 col-sm-6 col-md-6 icon-section">
<i class="fa fa-handshake-o" aria-hidden="true"></i>
</div>
<div class="col-xs-12 col-sm-6 col-md-6">
<div class="split-text">
<div class="split-title">
<h2>{% trans "Reliable and light" %}</h2>
</div>
<div class="split-description">
<p class="lead">{% trans "Our VMs are located in Switzerland, with reliable power supply and fast internet connection. Our VM costs less thanks to our featherlight infrastructure." %}</p>
</div>
</div>
</div>
</div>
</div>
<!-- /.container -->
<!-- /.option 1 -->
</div>
<!-- /.content-section-b -->
<div class="content-section-a pricing-section" id="price">
<div class="container">
<!-- Page Features -->
<div class="row text-center">
<div class="col-xs-12 col-md-6 text">
<h2 class="section-heading">{% trans "Simple and affordable: Try our virtual machine with featherlight price." %}</h2>
<p class="lead">{% trans "Affordable VM hosting based in Switzerland" %}</p>
</div>
<div class="col-xs-12 col-md-6 hero-feature">
<div class="price-calc-section no-padding">
<div class="landing card">
<img class="img-beta" src="{% static 'datacenterlight/img/beta-img.png' %}" alt="">
<div class="caption">
<form id="order_form" method="POST" action="">
{% csrf_token %}
<div class="title">
<h3>{% trans "VM hosting" %} </h3>
</div>
<div class="price">
<span id="total">15</span>
<span>CHF/{% trans "month" %}</span>
</div>
<div class="descriptions">
<div class="description">
<p>{% trans "Hosted in Switzerland" %}</p>
</div>
<div class="description">
<i class="fa fa-minus-circle left" data-minus="cpu" aria-hidden="true"></i>
<input class="input-price" type="number" min="1" max="42" id="coreValue" name="cpu">
<span> Core</span>
<i class="fa fa-plus-circle right" data-plus="cpu" aria-hidden="true"></i>
</div>
<div class="description">
<i class="fa fa-minus-circle left" data-minus="ram" aria-hidden="true"></i>
<input id="ramValue" class="input-price" type="number" min="2" max="200" name="ram">
<span> GB RAM</span>
<i class="fa fa-plus-circle right" data-plus="ram" aria-hidden="true"></i>
</div>
<div class="description">
<i class="fa fa-minus-circle left" data-minus="storage" aria-hidden="true"></i>
<input id="storageValue" class="input-price" type="number" min="10" max="500" step="10" name="storage">
<span>{% trans "GB Storage (SSD)" %}</span>
<i class="fa fa-plus-circle right" data-plus="storage" aria-hidden="true"></i>
</div>
<div class="description select-configuration input">
<label for="config">OS</label>
<select name="config" id="">
{% for template in templates %}
<option value="{{template.id}}">{{template.name}} </option>
{% endfor %}
</select>
</div>
<input type="hidden" name="total">
<!--<div class="description check-ip">
<input type="checkbox" name="ipv6"> Ipv6 Only<br>
</div>-->
<div class="description input">
<label for="name">{% trans "Name"%}</label>
<input type="text" name="name" placeholder="{% trans "Your Name" %}">
</div>
<div class="description input">
<label for="email">{% trans "Email" %}</label>
<input type="email" name="email" placeholder="{% trans "Your Email" %}">
</div>
</div>
<input type="submit" class="btn btn-primary" value="{% trans 'Order Now!' %}"></input>
</form>
</div>
<div>
<div id="error_message_box" class="error-message-box"></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Configure -->
<!-- <div class="request-section" id="request">
<div class="container">
<div class="row">
<div class="col-sm-6 col-md-6">
<div class="title">
<h2>{% trans "I want to have it!" %}</h2>
</div>
</div>
<div class="col-sm-6 col-md-6">
<!-- Beta access form, will be loaded via ajax
<div class="form" id="beta_access_form">
</div>
</div>
</div>
</div>
</div> -->
<!-- /.content-section-a -->
<!-- / contact section -->
<div class="full-contact-section">
<div class="intro-header-2 contact-section" id="contact">
<div class="container">
<div class="row">
<div class="col-sm-6 col-md-6">
<div class="card">
<div class="subtitle">
<h3>ungleich GmbH </h3>
</div>
<div class="description">
<p><i class="fa fa-envelope-o"></i> info@datacenterlight.ch</p>
<p>In der Au 7, Schwanden 8762</p>
<p>{% trans "Switzerland " %}</p>
</div>
<div class="social">
<a target="_blank" class="" href="https://twitter.com/datacenterlight">
<i class="fa fa-twitter fa-fw"></i>
</a>
<a target="_blank" class="" href="https://github.com/ungleich">
<i class="fa fa-github fa-fw"></i>
</a>
<a target="_blank" class="" href="https://www.facebook.com/ungleich.ch/">
<i class="fa fa-facebook fa-fw"></i>
</a>
</div>
</div>
</div>
<div class="col-sm-6 col-md-6">
<div class="title">
<h2>{% trans "Questions?" %} {% trans "Contact us!" %}</h2>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- /.banner -->
{% endblock %}

View file

View file

@ -0,0 +1,24 @@
from django import template
from django.core.urlresolvers import resolve, reverse
from django.utils.translation import activate, get_language
register = template.Library()
@register.simple_tag(takes_context=True)
def change_lang(context, lang=None, *args, **kwargs):
path = context['request'].path
url_parts = resolve( path )
url = path
cur_language = get_language()
try:
activate(lang)
url = reverse( url_parts.view_name, kwargs=url_parts.kwargs )
finally:
activate(cur_language)
return "%s" % url

View file

@ -236,7 +236,7 @@ class BetaProgramView(CreateView):
class IndexView(CreateView):
template_name = "datacenterlight/home.html"
template_name = "datacenterlight/index.html"
model = BetaAccess
form_class = BetaAccessForm
success_url = "/datacenterlight#requestform"

View file

@ -110,6 +110,7 @@ INSTALLED_APPS = (
'digitalglarus',
'nosystemd',
'datacenterlight',
'datacenterlight.templatetags',
'alplora',
'rest_framework',
'opennebula_api'