contrib/opportunity: prepare for i18n by separating the localized strings from the...
authorAlexis Laferrière <alexis.laf@xymus.net>
Fri, 19 Jun 2015 15:01:24 +0000 (11:01 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Sun, 21 Jun 2015 21:09:20 +0000 (17:09 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

contrib/opportunity/src/templates/boilerplate.nit
contrib/opportunity/src/templates/meetup.nit
contrib/opportunity/src/templates/meetup_confirmation.nit
contrib/opportunity/src/templates/meetup_creation.nit
contrib/opportunity/src/templates/welcome.nit

index a92ab4b..1a16449 100644 (file)
 # limitations under the License
 
 # Contains the main components of a webpage for Opportunity
-module boilerplate
+module boilerplate is i18n
 
 import template
+import gettext
 
 # Header for a Opportunity page
 class OpportunityHeader
@@ -29,7 +30,7 @@ class OpportunityHeader
 <!DOCTYPE html>
 <html>
 <head>
-       <title>Opportunity - The meetup planner</title>
+       <title>{{{"Opportunity - The meetup planner"}}}</title>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
@@ -69,14 +70,13 @@ class OpportunityHeader
 <nav class="menu" role="navigation">
        <div class="container">
                <div class="navbar-header">
-                       <a class="navbar-brand" href="./" >Opportunity</a>
+                       <a class="navbar-brand" href="./" >{{{"Opportunity"}}}</a>
                </div>
        </div>
 </nav>
 <div class="container">
 """
        end
-
 end
 
 # Footer for a Opportunity page
@@ -89,10 +89,10 @@ class OpportunityFooter
 <div class="footer">
        <div class="well well-sm">
                <p class="text-muted text-center">
-                       Opportunity, the meetup planner.
+                       {{{"Opportunity, the meetup planner."}}}
                </p>
                <p class="text-muted text-center">
-                       Proudly powered by <a href="http://nitlanguage.org/">Nit</a>!
+                       {{{"Proudly powered by %1!".format("<a href=\"http://nitlanguage.org/\">Nit</a>")}}}
                </p>
        </div>
 </div>
@@ -100,7 +100,6 @@ class OpportunityFooter
 </html>
 """
        end
-
 end
 
 # Any Opportunity page that contains the header, body and footer.
index 07a5f66..0358f33 100644 (file)
@@ -13,7 +13,7 @@
 # limitations under the License
 
 # Shows a meetup and allows to modify its participants
-module meetup
+module meetup is i18n
 
 import opportunity_model
 import boilerplate
@@ -231,14 +231,14 @@ class OpportunityMeetupPage
                function modify_people(ele, id){
                        if (in_modification_id != null) {
                                // reset to normal values
-                               $('#modify_'+in_modification_id).text("Modify or delete");
+                               $('#modify_'+in_modification_id).text("{{{"Modify or delete"}}}");
                                $('#modify_'+in_modification_id).attr("class", "btn btn-xs btn-warning");
                                $('#line_'+in_modification_id).css("background-color", "");
                                $('#delete_'+in_modification_id).css("display", "none");
                        }
                        if (in_modification_id != id) {
                                // activate modifiable mode
-                               $('#modify_'+id).text("Done");
+                               $('#modify_'+id).text("{{{"Done"}}}");
                                $('#modify_'+id).attr("class", "btn btn-xs btn-success");
                                $('#line_'+id).css("background-color", "LightYellow");
                                $('#delete_'+id).show();
@@ -274,16 +274,16 @@ redef class Meetup
        <center><h1>{{{name}}}</h1></center>
 """
                if not date.is_empty then t.add """
-       <center><h4>When: {{{date}}}</h4></center>"""
+       <center><h4>{{{"When:"}}} {{{date}}}</h4></center>"""
 
                if not place.is_empty then t.add """
-       <center><h4>Where: {{{place}}}</h4></center>"""
+       <center><h4>{{{"Where:"}}} {{{place}}}</h4></center>"""
 
                t.add """
 </div>
 <table class="table">
 """
-               t.add "<th>Participant name</th>"
+               t.add "<th>{"Participant name"}</th>"
                for i in answers(db) do
                        t.add "<th class=\"text-center\">"
                        t.add i.to_s
@@ -333,19 +333,19 @@ redef class Meetup
                                end
                                t.add "</center></td>"
                        end
-                       t.add """<td class="opportunity-action"><center><button class="btn btn-xs btn-warning" type="button" onclick="modify_people(this, {{{i.id}}})" id="modify_{{{i.id}}}">Modify or delete</button>&nbsp;"""
-                       t.add """<button class="btn btn-xs btn-danger" type="button" onclick="remove_people(this)" id="delete_{{{i.id}}}" style="display: none;">Delete</button></center></td>"""
+                       t.add """<td class="opportunity-action"><center><button class="btn btn-xs btn-warning" type="button" onclick="modify_people(this, {{{i.id}}})" id="modify_{{{i.id}}}">{{{"Modify or delete"}}}</button>&nbsp;"""
+                       t.add """<button class="btn btn-xs btn-danger" type="button" onclick="remove_people(this)" id="delete_{{{i.id}}}" style="display: none;">{{{"Delete"}}}</button></center></td>"""
                        t.add "</tr>"
                end
                t.add """
 <tr id="newrow" style="background-color: LightYellow">
-       <td><input id="new_name" type="text" placeholder="Your name" class="input-large"></td>
+       <td><input id="new_name" type="text" placeholder="{{{"Your name"}}}" class="input-large"></td>
                """
                for i in answers(db) do
                        t.add "<td class=\"answer\" id=\"newans_{i.id}\" onclick=\"change_temp_answer(this)\" style=\"color:red;\"><center>✘</center></td>"
                end
                t.add """
-       <td><center><span id="add_{{{id}}}" onclick="add_part(this)" style="color:green;" class="action"><button class="btn btn-xs btn-success" type="button">Done</button></span></center></td>"""
+       <td><center><span id="add_{{{id}}}" onclick="add_part(this)" style="color:green;" class="action"><button class="btn btn-xs btn-success" type="button">{{{"Done"}}}</button></span></center></td>"""
                t.add "</tr>"
                # Compute score for each answer
                var scores = new HashMap[Int, Int]
index 8771795..648f4da 100644 (file)
@@ -13,7 +13,7 @@
 # limitations under the License
 
 # Page to show when the creation of a Meetup is successful
-module meetup_confirmation
+module meetup_confirmation is i18n
 
 import boilerplate
 import opportunity_model
@@ -27,14 +27,14 @@ class MeetupConfirmation
        init do
                body = """
                <div class="page-header">
-                       <center><h1>Your meetup was successfully created</h1></center>
+                       <center><h1>{{{"Your meetup was successfully created"}}}</h1></center>
                </div>
                <div class="container">
                        <div class="alert alert-success text-center" role="alert">
-                       Invite participants by sharing this link: <a href="./?meetup_id={{{meetup.id}}}">{{{meetup.name}}}</a>
+                       {{{"Invite participants by sharing this link:"}}} <a href="./?meetup_id={{{meetup.id}}}">{{{meetup.name}}}</a>
                        </div>
                        <p class="text-center">
-                       See you soon for more Opportunities!
+                       {{{"See you soon for more Opportunities!"}}}
                        </p>
                </div>
                """
index 5b1a048..8c2ab3d 100644 (file)
@@ -12,7 +12,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License
 
-module meetup_creation
+module meetup_creation is i18n
 
 import boilerplate
 import opportunity_model
@@ -49,7 +49,7 @@ function new_answer(sender){
        ansdiv.append('<div class="form-group">' +
                '<label for="answer_' + nb + '" class="col-sm-4 control-label">' + nb + '</label>' +
                '<div class="col-sm-8">' +
-                       '<input name="answer_' + nb + '" id="answer_' + nb + '" class="form-control" type="text" placeholder="Another opportunity">' +
+                       '<input name="answer_' + nb + '" id="answer_' + nb + '" class="form-control" type="text" placeholder="{{{"Another opportunity"}}}">' +
                '</div></div>')
 }
 """
@@ -63,7 +63,7 @@ function new_answer(sender){
                if error != null then
                        bdy.add "<p></p>"
                        bdy.add """<div class="alert alert-danger alert-dismissible" role="alert">
-                               <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
+                               <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">{{{"Close"}}}</span></button>
                                """
                        bdy.add error.as(not null)
                        bdy.add "</div>"
@@ -71,35 +71,35 @@ function new_answer(sender){
 
                bdy.add """
                <div class="page-header">
-                       <center><h1>Create a meetup</h1></center>
+                       <center><h1>{{{"Create a meetup"}}}</h1></center>
                </div>
                """
                bdy.add """<form class="form-horizontal" action="meetup_create" method="POST" role="form">
                        <div class = "form-group">
-                               <label for="meetup_name" class="col-sm-4 control-label">Meetup name</label>
+                               <label for="meetup_name" class="col-sm-4 control-label">{{{"Meetup name"}}}</label>
                                <div class="col-sm-8">
-                                       <input name="meetup_name" id="meetup_name" type="text" class="form-control" placeholder="My Event" value="{{{if meet != null then meet.name else ""}}}" />
+                                       <input name="meetup_name" id="meetup_name" type="text" class="form-control" placeholder="{{{"My Event"}}}" value="{{{if meet != null then meet.name else ""}}}" />
                                </div>
                        </div>
                        <div class = "form-group">
-                               <label for="meetup_date" class="col-sm-4 control-label">When?</label>
+                               <label for="meetup_date" class="col-sm-4 control-label">{{{"When?"}}}</label>
                                <div class="col-sm-8">
-                                       <input name="meetup_date" id="meetup_date" type="text" class="form-control" placeholder="Time of the event" value="{{{if meet != null then meet.date else ""}}}">
+                                       <input name="meetup_date" id="meetup_date" type="text" class="form-control" placeholder="{{{"Time of the event"}}}" value="{{{if meet != null then meet.date else ""}}}">
                                </div>
                        </div>
                        <div class = "form-group">
-                               <label for="meetup=place" class="col-sm-4 control-label">Where?</label>
+                               <label for="meetup=place" class="col-sm-4 control-label">{{{"Where?"}}}</label>
                                <div class="col-sm-8">
-                                       <input name="meetup_place" id="meetup_place" type="text" class="form-control" placeholder="Place of the event" value="{{{if meet != null then meet.place else ""}}}">
+                                       <input name="meetup_place" id="meetup_place" type="text" class="form-control" placeholder="{{{"Place of the event"}}}" value="{{{if meet != null then meet.place else ""}}}">
                                </div>
                        </div>
                        <div class = "form-group">
-                               <label for="meetup=maybe" class="col-sm-4 control-label">Add a Maybe option?</label>
+                               <label for="meetup=maybe" class="col-sm-4 control-label">{{{"Add a Maybe option?"}}}</label>
                                <div class="col-sm-8">
                                        <input name="meetup_mode" id="meetup_mode" type="checkbox" class="form-control">
                                </div>
                        </div>
-                               <h2>Opportunities</h2>
+                               <h2>{{{"Opportunities"}}}</h2>
 <div id="answers">
 """
 
@@ -139,8 +139,8 @@ function new_answer(sender){
                bdy.add """
                        </div>
                        <div class="form-group">
-                               <button type="button" class="btn btn-lg" onclick="new_answer(this)">Add an opportunity</button>
-                               <button type="submit" class="btn btn-lg btn-success">Create meetup</button>
+                               <button type="button" class="btn btn-lg" onclick="new_answer(this)">{{{"Add an opportunity"}}}</button>
+                               <button type="submit" class="btn btn-lg btn-success">{{{"Create meetup"}}}</button>
                        </div>
                </form>
                </center>
index 08f7696..2d321da 100644 (file)
@@ -13,7 +13,7 @@
 # limitations under the License
 
 # Welcome page for Opportunity
-module welcome
+module welcome is i18n
 
 import boilerplate
 
@@ -24,18 +24,17 @@ class OpportunityHomePage
        init do
                body = """
                <div class="page-header">
-               <h1 class="text-center">Welcome to Opportunity!</h1>
+               <h1 class="text-center">{{{"Welcome to Opportunity!"}}}</h1>
                        </div>
                        <p class="text-center">
-                               <p class="text-center">Opportunity is a free (as in free software), easy-to-use, meetup planner.</p>
-                               <p class="text-center">You can start using it right now by creating a new Meetup and sharing it with your friends!</p>
+                               <p class="text-center">{{{"Opportunity is a free (as in free software), easy-to-use, meetup planner."}}}</p>
+                               <p class="text-center">{{{"You can start using it right now by creating a new Meetup and sharing it with your friends!"}}}</p>
                                <p class="text-center">
                                <form action="new_meetup">
-                               <button type="submit" class="btn btn-lg center-block btn-success">Create a Meetup</button>
+                               <button type="submit" class="btn btn-lg center-block btn-success">{{{"Create a Meetup"}}}</button>
                                </form>
                                </p>
                        </p>
 """
        end
-
 end