-
-
Notifications
You must be signed in to change notification settings - Fork 28
Use I18n for month select #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,6 +70,18 @@ | |
expect(page.find('#user_date_of_birth_3i').value).to eq('2') | ||
end | ||
|
||
it 'finds and fills a spanish locale date field' do | ||
I18n.locale = :es | ||
visit 'user_form' | ||
form = Formulaic::Form.new(:user, :new, date_of_birth: Date.new(1980, 1, 2)) | ||
form.fill | ||
|
||
expect(page.find('#user_date_of_birth_1i').value).to eq('1980') | ||
expect(page.find('#user_date_of_birth_2i').value).to eq('1') | ||
expect(page.find('#user_date_of_birth_3i').value).to eq('2') | ||
I18n.locale = :en | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. great suggestion! |
||
end | ||
|
||
it 'finds and checks a boolean field' do | ||
visit 'user_form' | ||
form = Formulaic::Form.new(:user, :new, terms_of_service: true) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,205 @@ | ||
<form accept-charset="UTF-8" action="/users" class="simple_form new_user" id="new_user" method="post" novalidate="novalidate"> | ||
<div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓"><input name="authenticity_token" type="hidden" value="O6ORla31JvEaWroCuiA7bArM15ztDotMfPAbNW0v61g="></div> | ||
<div class="input string required user_name"><label class="string required" | ||
for="user_name"><abbr title="required">*</abbr> Your Display name</label><input class="string required" id="user_name" maxlength="255" name="user[name]" size="50" type="text"></div> | ||
<div class="input email required user_email"><label class="email required" | ||
for="user_email"><abbr title="required">*</abbr> Your Email</label><input class="string email required" id="user_email" maxlength="255" name="user[email]" size="50" type="email"></div> | ||
<div class="input tel required user_phone"><label class="tel required" for="user_phone"><abbr title="required">*</abbr> Phone Number</label><input class="string phone required" id="user_phone" maxlength="255" name="user[phone]" size="50" type="tel"></div> | ||
<div class="input integer required user_age"><label class="integer required" | ||
for="user_age"><abbr title="required">*</abbr> Your Age</label><input class="numeric integer age required" id="user_age" maxlength="255" name="user[age]" size="50" type="number"></div> | ||
<div class="input url required user_url"><label class="tel required" for="user_url"><abbr title="required">*</abbr> Website</label><input class="string url required" id="user_url" maxlength="255" name="user[url]" size="50" type="url"></div> | ||
<div class="input file optional user_avatar"><label class="file optional" | ||
for="user_avatar">Your Avatar</label><input class="file optional" id="user_avatar" name="user[avatar]" type="file" /></div> | ||
<div class="input password optional user_password"><label class="password | ||
optional" for="user_password">Your Password</label><input class="password optional" id="user_password" name="user[password]" size="50" type="password"></div> | ||
<div class="input select required user_awesome"> | ||
<label class="select required" for="user_awesome"><abbr title="required">*</abbr> Are you awesome?</label> | ||
<select class="select required" id="user_awesome" name="user[awesome]"> | ||
<option value=""></option> | ||
<option value="true">Yes</option> | ||
<option value="false">No</option> | ||
</select> | ||
</div> | ||
<div class="input select user_likes"> | ||
<label class="select" for="user_likes">Your Likes</label> | ||
<select class="select" id="user_likes" name="user[likes][]" multiple> | ||
<option value=""></option> | ||
<option value="ruby">Ruby</option> | ||
<option value="rails">Rails</option> | ||
<option value="git">Git</option> | ||
</select> | ||
</div> | ||
<div class="input check_boxes optional user_dislikes"> | ||
<label class="check_boxes optional">Your Dislikes</label> | ||
<span class="checkbox"> | ||
<input class="check_boxes optional" id="user_dislikes_1" name="user[dislikes][]" type="checkbox" value="java"> | ||
<label class="collection_check_boxes" for="user_dislikes_1">Java</label> | ||
</span> | ||
<span class="checkbox"> | ||
<label class="collection_check_boxes" for="user_dislikes_2"> | ||
PHP | ||
<input class="check_boxes optional" id="user_dislikes_2" name="user[dislikes][]" type="checkbox" value="php"> | ||
</label> | ||
</span> | ||
<input name="user[dislikes][]" type="hidden" value=""> | ||
</div> | ||
<div class="input text required user_bio"><label class="text required" | ||
for="user_bio"><abbr title="required">*</abbr> Your Biography</label><textarea class="text required" cols="40" id="user_bio" name="user[bio]" rows="20" style="overflow: hidden; word-wrap: break-word; resize: horizontal; height: 464px;"></textarea></div> | ||
<div class="input date required user_date_of_birth"> | ||
<label class="date required" for="user_date_of_birth_1i"><abbr | ||
title="required">*</abbr> Your Date of birth</label> | ||
<select class="date required" id="user_date_of_birth_1i" name="user[date_of_birth(1i)]"> | ||
<option value="2001">2001</option> | ||
<option value="2000">2000</option> | ||
<option value="1999">1999</option> | ||
<option value="1998">1998</option> | ||
<option value="1997">1997</option> | ||
<option value="1996">1996</option> | ||
<option value="1995">1995</option> | ||
<option value="1994">1994</option> | ||
<option value="1993">1993</option> | ||
<option value="1992">1992</option> | ||
<option value="1991">1991</option> | ||
<option value="1990">1990</option> | ||
<option value="1989">1989</option> | ||
<option value="1988">1988</option> | ||
<option value="1987">1987</option> | ||
<option value="1986">1986</option> | ||
<option value="1985">1985</option> | ||
<option value="1984">1984</option> | ||
<option value="1983">1983</option> | ||
<option value="1982">1982</option> | ||
<option value="1981">1981</option> | ||
<option value="1980">1980</option> | ||
<option value="1979">1979</option> | ||
<option value="1978">1978</option> | ||
<option value="1977">1977</option> | ||
<option value="1976">1976</option> | ||
<option value="1975">1975</option> | ||
<option value="1974">1974</option> | ||
<option value="1973">1973</option> | ||
<option value="1972">1972</option> | ||
<option value="1971">1971</option> | ||
<option value="1970">1970</option> | ||
<option value="1969">1969</option> | ||
<option value="1968">1968</option> | ||
<option value="1967">1967</option> | ||
<option value="1966">1966</option> | ||
<option value="1965">1965</option> | ||
<option value="1964">1964</option> | ||
<option value="1963">1963</option> | ||
<option value="1962">1962</option> | ||
<option value="1961">1961</option> | ||
<option value="1960">1960</option> | ||
<option value="1959">1959</option> | ||
<option value="1958">1958</option> | ||
<option value="1957">1957</option> | ||
<option value="1956">1956</option> | ||
<option value="1955">1955</option> | ||
<option value="1954">1954</option> | ||
<option value="1953">1953</option> | ||
<option value="1952">1952</option> | ||
<option value="1951">1951</option> | ||
<option value="1950">1950</option> | ||
<option value="1949">1949</option> | ||
<option value="1948">1948</option> | ||
<option value="1947">1947</option> | ||
<option value="1946">1946</option> | ||
<option value="1945">1945</option> | ||
<option value="1944">1944</option> | ||
<option value="1943">1943</option> | ||
<option value="1942">1942</option> | ||
<option value="1941">1941</option> | ||
<option value="1940">1940</option> | ||
<option value="1939">1939</option> | ||
<option value="1938">1938</option> | ||
<option value="1937">1937</option> | ||
<option value="1936">1936</option> | ||
<option value="1935">1935</option> | ||
<option value="1934">1934</option> | ||
<option value="1933">1933</option> | ||
<option value="1932">1932</option> | ||
<option value="1931">1931</option> | ||
<option value="1930">1930</option> | ||
<option value="1929">1929</option> | ||
<option value="1928">1928</option> | ||
<option value="1927">1927</option> | ||
<option value="1926">1926</option> | ||
<option value="1925">1925</option> | ||
<option value="1924">1924</option> | ||
<option value="1923">1923</option> | ||
<option value="1922">1922</option> | ||
<option value="1921">1921</option> | ||
<option value="1920">1920</option> | ||
<option value="1919">1919</option> | ||
<option value="1918">1918</option> | ||
<option value="1917">1917</option> | ||
<option value="1916">1916</option> | ||
<option value="1915">1915</option> | ||
<option value="1914">1914</option> | ||
<option value="1913">1913</option> | ||
<option value="1912">1912</option> | ||
<option value="1911">1911</option> | ||
<option value="1910">1910</option> | ||
<option value="1909">1909</option> | ||
<option value="1908">1908</option> | ||
<option value="1907">1907</option> | ||
<option value="1906">1906</option> | ||
<option value="1905">1905</option> | ||
<option value="1904">1904</option> | ||
<option value="1903">1903</option> | ||
<option value="1902">1902</option> | ||
<option value="1901">1901</option> | ||
<option value="1900">1900</option> | ||
</select> | ||
<select class="date required" id="user_date_of_birth_2i" name="user[date_of_birth(2i)]"> | ||
<option value="1">Enero</option> | ||
<option value="2">February</option> | ||
<option value="3">Marzo</option> | ||
<option value="4">Abril</option> | ||
<option value="5">Mayo</option> | ||
<option selected="selected" value="6">Junio</option> | ||
<option value="7">Julio</option> | ||
<option value="8">Agosto</option> | ||
<option value="9">Septiembre</option> | ||
<option value="10">Octubre</option> | ||
<option value="11">Noviembre</option> | ||
<option value="12">Diciembre</option> | ||
</select> | ||
<select class="date required" id="user_date_of_birth_3i" name="user[date_of_birth(3i)]"> | ||
<option value="1">1</option> | ||
<option value="2">2</option> | ||
<option value="3">3</option> | ||
<option value="4">4</option> | ||
<option value="5">5</option> | ||
<option value="6">6</option> | ||
<option selected="selected" value="7">7</option> | ||
<option value="8">8</option> | ||
<option value="9">9</option> | ||
<option value="10">10</option> | ||
<option value="11">11</option> | ||
<option value="12">12</option> | ||
<option value="13">13</option> | ||
<option value="14">14</option> | ||
<option value="15">15</option> | ||
<option value="16">16</option> | ||
<option value="17">17</option> | ||
<option value="18">18</option> | ||
<option value="19">19</option> | ||
<option value="20">20</option> | ||
<option value="21">21</option> | ||
<option value="22">22</option> | ||
<option value="23">23</option> | ||
<option value="24">24</option> | ||
<option value="25">25</option> | ||
<option value="26">26</option> | ||
<option value="27">27</option> | ||
<option value="28">28</option> | ||
<option value="29">29</option> | ||
<option value="30">30</option> | ||
<option value="31">31</option> | ||
</select> | ||
</div> | ||
<div class="input boolean required user_terms_of_service"><input name="user[terms_of_service]" type="hidden" value="0"><input class="boolean required" id="user_terms_of_service" name="user[terms_of_service]" type="checkbox" value="1"><label class="boolean required" for="user_terms_of_service"><abbr title="required">*</abbr> I agree to the Terms of Service</label></div> | ||
<input name="commit" type="submit" value="Register"> | ||
</form> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,11 @@ def input(model, field) | |
end | ||
|
||
def visit(page_name) | ||
page.visit("/#{page_name}.html") | ||
if I18n.locale == :es | ||
page.visit("/#{page_name}_#{I18n.locale}.html") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah. This may be a little more clever than we need. Can we rely on explicitly visiting the |
||
else | ||
page.visit("/#{page_name}.html") | ||
end | ||
end | ||
|
||
def page | ||
|
@@ -36,6 +40,23 @@ def load_translations | |
terms_of_service: I agree to the Terms of Service | ||
url: Website | ||
TRANSLATIONS | ||
I18n.backend.store_translations(:es, YAML.load(<<-TRANSLATIONS)) | ||
date: | ||
month_names: | ||
- | ||
- Enero | ||
- Febrero | ||
- Marzo | ||
- Abril | ||
- Mayo | ||
- Junio | ||
- Julio | ||
- Agosto | ||
- Septiembre | ||
- Octubre | ||
- Noviembre | ||
- Diciembre | ||
TRANSLATIONS | ||
end | ||
end | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be
visit user_form_es
?